请原谅我的蹩脚问题,但我卡住了。在我的 routes.rb 文件中简单明了,我有:
resource :books do
resource :reviews
end
运行 rake 路线 | grep 评论给了我:
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
我的问题是:显示和编辑操作中的 :id 参数在哪里?根据本教程:http : //guides.rubyonrails.org/routing.html 路由中应该有“id”参数,如下所示:
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
除此之外,显示、更新和销毁操作的路线在哪里?我想我错过了一些基本的东西,因为这真的很糟糕。运行 Rails 3.2.11 感谢帮助