我知道member
和collection
与resources
不一样。
但如何为resource
。您是否使用member
和collection
作为resource
?资源是否需要会员或收藏?
我发现
resource :foo do
patch :confirm
end
和
resource :foo do
member do
patch :confirm
end
end
和
resource :foo do
collection do
patch :confirm
end
end
相同。
路线=> /foo/confirm(.:format)
方法=> PATCH
行动=> FoosController#确认
名称=> confirm_foo
没有为resource block
文件,只有约resources block
。
Rails Routing from the Outside In — Ruby on Rails Guides
resource
使用没有member
或collection
是集呢? member
或collection
或没有使用这些,这是最佳做法?
的'resource'方法[是有据可查的](http://guides.rubyonrails.org/routing.html#单数资源)仔细阅读。 –
是的。但不说会员和收藏。 –
我不清楚你问什么。 _是否正确?_哪种方式?你可以使用你想要的东西,完全取决于你的应用程序逻辑,什么是'member'或'collection'使用'confirm'动作。 'member' for member,'collection' for collection。 –