[英]Alias for Devise URL Rails
I am new to Ruby on Rails,I am using Devise gem for authentication on table account_user. 我是Ruby on Rails的新手,正在使用Devise gem在表account_user上进行身份验证。 When I do rake routes
I get 当我做rake routes
我得到
new_account_user_session GET /account_users/sign_in(.:format)account_user/sessions#new
So my login page is xyz.com/account_users/sign_in
. 所以我的登录页面是xyz.com/account_users/sign_in
。 I want to change the sign-in page to just xyz.com
我想将登录页面更改为xyz.com
I don't have any routes for the same in my routes.rb file, I thought devise is automatically generating routes for this. 我的route.rb文件中没有相同的路由,我认为devise会为此自动生成路由。
Is there a way I can add alias/override for this devise generated routes, or redirect user to xyz.com
instead of xyz.com/account_users/sign_in
有没有一种方法可以为此设计生成的路由添加别名/替代,或将用户重定向到xyz.com
而不是xyz.com/account_users/sign_in
set root to devise sign_in, so in your route file there should be 设置root来设计sign_in,因此在您的路由文件中应该有
devise_for :account_users
devise_scope :account_user do
root to: 'devise/sessions#new'
end
this will set your root path to sign_in 这会将您的根路径设置为sign_in
or if you want to rename the route to 'login' 或者如果您要将路线重命名为“登录”
devise_for :account_users
devise_scope :account_user do
get 'login', to: 'devise/sessions#new'
end
more here https://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes 更多详情,请访问https://github.com/plataformatec/devise/wiki/操作方法:-更改-default-sign_in-and-sign_out-routes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.