兩種型號:Window
(belongs_to的:window_input)和WindowInput
(的has_many:窗口),當我把這個routes.rb中:Rails的嵌套路由去瘋狂
resources :window_inputs do
resource :window
end
的rake routes
結果是:
new_window_inputs_window GET /window_inputs/windows/new(.:format)
正確的路由應該是:/window_inputs/:window_input_id/windows/new(.:format)
。我想知道這個錯誤來自兩個模型的名字。我使用sqlite和rails 3.2.2。任何人都可以幫助我呢?簡單地命名空間,不依賴除非你指的這種方式
resources :window_inputs do |window_inputs|
window_inputs.resources :windows
end
它宣稱,:嵌套聲明第二資源爲第一的兒童在
這是我的錯。忘了's':'resource * s *:window'。 – schemacs 2012-03-05 15:06:01
請參閱[本](http://stackoverflow.com/questions/6353023/rails-3-nested-resources-routing)。 – schemacs 2012-03-05 15:08:01