Changing devise default layouts

If you name your alternate layout devise.html.erb, then the gem's controllers will naturally use it, without needing to be asked. Saves some code.


Add this lines of code to your application.rb:

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

If you want the same layout for all Devise views, except for when the user is editing its data, you could have something like this:

config.to_prepare do
  Devise::SessionsController.layout "your_layout_name"
  Devise::RegistrationsController.layout proc{ |controller| user_signed_in? ? "application" : "your_layout_name" }
  Devise::ConfirmationsController.layout "your_layout_name"
  Devise::UnlocksController.layout "your_layout_name"            
  Devise::PasswordsController.layout "your_layout_name"        
end

For more information you can read this article