【发布时间】:2012-07-07 05:47:40
【问题描述】:
我定义了以下路线:
resources :employees do
resources :questions
member do
get :results
end
end
上述资源的其中一条路由(rake 路由)打印如下:
new_employee_question GET /employees/:employee_id/questions/new(.:format) questions#new
但是当我这样做时= link_to 'New Question', :new_employee_question
我收到以下错误:
No route matches {:action=>"new", :controller=>"questions"}
我用所需的操作方法定义了 QuestionsController 和 EmployeesController。
我还在 Rails 控制台中尝试了以下操作:
Rails.application.routes.recognize_path(app.new_employee_question_path)
...生成以下错误:
ActionController::RoutingError: No route matches {:controller=>"questions"}
我正在使用 Rails 3.2.6。是不是我做错了什么?
【问题讨论】:
标签: ruby-on-rails-3 routes nested-routes