So I created some rspec_scaffold for an Exercise model and added "map.resource :exercises" to my routes file and I was surprised when the "/exercises" url rendered the show action. What the heck? Why doesn't that render the index action?
rake routes
new_exercises GET /exercises/new(.:format) {:controller=>"exercises", :action=>"new"}
edit_exercises GET /exercises/edit(.:format) {:controller=>"exercises", :action=>"edit"}
exercises GET /exercises(.:format) {:controller=>"exercises", :action=>"show"}
PUT /exercises(.:format) {:controller=>"exercises", :action=>"update"}
DELETE /exercises(.:format) {:controller=>"exercises", :action=>"destroy"}
POST /exercises(.:format) {:controller=>"exercises", :action=>"create"}
You set up a singular route when you used the word resource
. Use this instead.
map.resources :exercises
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With