Rails 6 为 Devise 设置 layout

环境

  • Rails: 6.1.3.2
  • Ruby: 3.0.1
  • Devise: 4.8.0

步骤

  1. 创建config/initializers/devise_layout_settings.rb文件,内容如下
Rails.application.configure do
  config.to_prepare do
    Devise::SessionsController.layout       "your_layout_name"
    Devise::RegistrationsController.layout  "your_layout_name"
    Devise::ConfirmationsController.layout  "your_layout_name"
    Devise::UnlocksController.layout        "your_layout_name"
    Devise::PasswordsController.layout      "your_layout_name"
  end
end

参考

Set Custom Layouts for Devise Controllers
Devise Wiki: "How To: Create custom layouts"

点赞

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注