更改设备默认布局 [英] Changing devise default layouts

查看:67
本文介绍了更改设备默认布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于更改设备默认布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆