我是rails的新手并尝试创建示例应用。我有
应用/ routes.rb中
Rails.application.routes.draw do
resources :books do
book.resources :comments, :only => :create
#root 'books#index'
end
end
不确定我为什么会收到以下错误
/bookshelf/config/routes.rb:3:in `block (2 levels) in <top (required)>': undefined local variable or method `book' for #<ActionDispatch::Routing::Mapper:0x007fdebb03e728> (NameError)
答案 0 :(得分:2)
删除“book。”
应该看起来像:
Rails.application.routes.draw do
resources :books do
resources :comments, only: :create
end
end