Search code examples
ruby-on-railslayoutdevise

Changing devise default layouts


I'm trying to get devise to display a different layout template from the defaults for certain aspects.

I have this working when the user goes to the login page, but I need to display a different layout for sign up, forgotten password, and reset.

This is the current code in my application controller:

layout :layout

  private
  def layout
    # only turn it off for login pages:
    is_a?(Devise::SessionsController) ? "login" : "application"
    # or turn layout off for every devise controller:
    #devise_controller? && "application"
  end

Solution

  • 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.