Reputation: 25
Excuse me for my lame question, but i`m stuck. Plain and simple in my routes.rb file i have:
resource :books do
resource :reviews
end
running rake routes | grep reviews gives me:
books_reviews POST /books/reviews(.:format) reviews#create
new_books_reviews GET /books/reviews/new(.:format) reviews#new
edit_books_reviews GET /books/reviews/edit(.:format) reviews#edit
GET /books/reviews(.:format) reviews#show
PUT /books/reviews(.:format) reviews#update
DELETE /books/reviews(.:format) reviews#destroy
My question is: where is the :id param in the show and edit actions? According to this tutorial: http://guides.rubyonrails.org/routing.html there should be "id" params in the routing, like this:
new_books_reviews GET /books/:id/reviews/new(.:format) reviews#new
edit_books_reviews GET /books/:id/reviews/edit(.:format) reviews#edit
GET /books/:id/reviews(.:format) reviews#show
On top of that where are the routes for show, update and destroy actions? I think i`m missing something fundamental, because this really sucks. Running Rails 3.2.11 Thanks for the help
Upvotes: 0
Views: 254
Reputation: 19809
Using resources
over resource
will make sure Rails accounts for many resources.
Your routes should look like this
resources :books do
resources :reviews
end
Upvotes: 0