多年前,我在 routes.rb 中使用类似的东西向用户发送不同的 URL:
unauthenticated do
devise_scope :user do
root :to => 'pages#home' , :as => :root_path
end
end
root to: 'pages#home_logged_in'
并且没有问题。我为经过身份验证的和未...用户获得了 root_path。
但现在我在谷歌搜索,只能找到这样的东西:
devise_scope :user do
authenticated :user do
root :to => 'pages#dashboard', as: :authenticated_root
end
unauthenticated :user do
root :to => 'session#new', as: :unauthenticated_root
end
end
所以我的“旧”方法不再起作用了?我不能为两种用户设置 root_path 吗?
当然第一个脚本不起作用,我总是redirect_to pages#home。
答案:
好的,现在我只需要添加 :user 。寻求帮助太快了:)
unauthenticated :user do
end