将用户从登录页面重定向到登录Rails并与Devise
答
在你的控制器动作的登录页面(注册可能,如果你使用的是色器件)。如果您还没有,则必须重写控制器。
def new
if current_user
redirect_to home_page_url
else
#current logic for sign in method (super) if you currently don't have it implemented
end
end
答
以下内容添加到您的routes.rb:
match "user_root", :to => "site#show" # where SiteController#show is your home page
答
我也从router.rb文件中发现了一种这样做的方法;这要比从路由器上做起来容易得多,这要求我重写设备控制器。
authenticated :admin do
root :to => 'admin/dashboard#show'
end
authenticated do
root :to => 'dashboard#show'
end
root :to => 'landing#show'
http://rubydoc.info/github/plataformatec/devise/master/ActionDispatch/Routing/Mapper:authenticated