ruby on rails - Not all member routes get an id in the querystring -
some member routes specific names not added expected :id
inside query string. these routes:
resources :tests member :foo end end resources :contacts member :foo end end resource :tasks member :foo end end resource :fruits member :foo end end resource :cars member :foo end end resources :appointments member :foo end end
produces this:
foo_test /tests/:id/foo(.:format) tests#foo foo_contact /contacts/:id/foo(.:format) contacts#foo foo_tasks /tasks/foo(.:format) tasks#foo foo_fruits /fruits/foo(.:format) fruits#foo foo_cars /cars/foo(.:format) cars#foo foo_appointment /appointments/:id/foo(.:format) appointments#foo
tasks, fruits , cars not have id. why that?
your problem in resource
(singular) vs resources
(plural). notice everytime have :id
in route (test, contact, appointments) declared using resources , otherwise using resource.
by using resource
(singular) implicitly saying have 1 resource of type there no need , id, that's why it's not present here.
you can find more infos here : difference between resource , resources methods
Comments
Post a Comment