0

I know member and collection is not same for resources.
but how about for resource. Are you use member and collection for resource?.

I found

resource :foo do
  patch :confirm
end

and

resource :foo do
  member do
    patch :confirm
  end
end

and

resource :foo do
  collection do
    patch :confirm
  end
end

are Same.

Route => /foo/confirm(.:format)
Method => PATCH
Action => FoosController#confirm
Name => confirm_foo

No document for resource block, only about resources block.
Rails Routing from the Outside In — Ruby on Rails Guides

resource use no member or collection is collect way? member or collection or no use these, which is best practice?

shingo.nakanishi
  • 2,045
  • 2
  • 21
  • 55
  • 1
    The `resource` method [is well documented](http://guides.rubyonrails.org/routing.html#singular-resources) read it carefully. – Roman Kiselenko Aug 22 '16 at 09:20
  • yes. but not say member and collection. – shingo.nakanishi Aug 22 '16 at 09:21
  • It's unclear for me what you asking. _is correct way?_ Which way? You can use what you want, it's totally depend on your application logic, for what is `confirm` action used for `member` or `collection`?. `member` for member, `collection` for collection. – Roman Kiselenko Aug 22 '16 at 09:24
  • I wont to add custom route for `Singular Resources`. There are many way. also `patch 'confirm', to: : confirm, controller: 'foos'`. I want to know how to use `resource block`. only `resources block` documented. – shingo.nakanishi Aug 22 '16 at 09:29
  • `member` and `collection` for `resources` is different. but I think these are same behavior for `resource`. – shingo.nakanishi Aug 22 '16 at 09:35

1 Answers1

1

Member and collection are not the same.

A member route will require an ID, because it acts on a member.

foo/:id/confirm

A collection route doesn't because it acts on a collection of objects.

foo/confirm

Similar: difference between collection route and member route in ruby on rails?

Adding more restful actions: http://guides.rubyonrails.org/routing.html#adding-more-restful-actions

Community
  • 1
  • 1
codyeatworld
  • 1,263
  • 7
  • 9