繁体   English   中英

Rails本地主机自定义登录页面与设计

[英]Rails localhost custom landing page with devise

Rails默认的localhost:3000映射到welcome_controller#index页面,我想在根目录中使用我的自定义登录页面。 我还使用devise进行身份验证设置。

当我给localhost:3000时,设备会自动重定向到localhost:3000 / users / sign_in。

如何更改自定义页面的根目录以及在何处放置index.html文件,以便可以看到登录页面。

您可以将其添加到routes.rb文件的顶部:

get "/" => "custom_controller#custom_action", as: :custom_root_path

这将为您提供以下路线:

custom_root_path   GET      /     custom_controller#custom_action

然后,你可以把你的自定义着陆页的内容相应的视图( custom_action.html.erb的文件) custom_controllercustom_action

例如,如果您将自定义控制器命名为landing_pages_controller ,并且操作是index ,则路由将是:

get "/" => "landing_pages#index", as: :custom_root_path

然后,您的landing_pages_controller.rb文件中将有一个index方法,并且将有一个app/views/landing_pages/index.html.erb文件,可在其中放置自定义登录页面的内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM