更改设备默认布局

问题描述:

在某些方面,我试图显示与默认设置不同的布局模板。

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


如果您命名您的替代布局devise.html.erb,则gem的控制器自然会使用它,而无需询问。保存一些代码。

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.