Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何更改已登录用户的根路径?_Ruby On Rails_Ruby On Rails 4_Devise - Fatal编程技术网

Ruby on rails 如何更改已登录用户的根路径?

Ruby on rails 如何更改已登录用户的根路径?,ruby-on-rails,ruby-on-rails-4,devise,Ruby On Rails,Ruby On Rails 4,Devise,如何在用户登录时更改根路径?(我正在使用Desive) 在应用程序控制器中,我有: def after_sign_in_path_for(resource) '/dashboard' || user_dashboard_path end 在routes.rb中,我尝试过: Rails.application.routes.draw do root to: "subscribers#new" authenticated :user do get '/dashb

如何在用户登录时更改根路径?(我正在使用Desive)

在应用程序控制器中,我有:

  def after_sign_in_path_for(resource)
    '/dashboard' || user_dashboard_path
  end
在routes.rb中,我尝试过:

Rails.application.routes.draw do

  root to: "subscribers#new"

  authenticated :user do
    get '/dashboard', to: 'dashboard#index', as: :dashboard
    root to: "dashboard#index", as: :user_dashboard
  end
但是现在发生的事情是,在注册后,它会重新定向到/dashboard,这很好,但是如果我单击链接到根路径的主链接,它会返回到订阅者#new,因为用户已登录,它应该在什么时候返回到dashboard#index

我做错了什么


谢谢

在路由文件中尝试以下操作:

authenticated :user do
  root to: "home#index"
end

unauthenticated :user do
  root "home#visitor"
end
此处的文档: