[英]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_controller
的custom_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.