【发布时间】:2013-07-02 13:34:04
【问题描述】:
如果我按原样使用以下代码 (dashboards#show),我会收到一条无法找到记录的错误 Couldn't find Dashboard without an ID,因为路径中没有用户 ID(我通常使用以下链接到此仪表板: user_dashboard_path(current_user, current_user.dashboard)
我想我需要将用户传递到设置根路径的代码块中,但我不确定如何实现。
有什么建议吗?
这是我的整个 routes.rb 文件:
MyApp::Application.routes.draw do
resources :users do
resources :dashboards, only: [:show, :edit, :update, :destroy]
end
authenticated :user do
# Instead of the show action, I want to go to user_dashboard which is
# GET /users/:user_id/dashboards/:id(.:format) dashboards#show
root :to => "dashboards#show", as: :authenticated_root
end
root :to => "home#index"
devise_for :users, :controllers => { :registrations => :registrations }
end
【问题讨论】:
标签: ruby-on-rails devise routing ruby-on-rails-4