将布局与Devise集成 [英] Integrate layouts with Devise

查看:153
本文介绍了将布局与Devise集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用devise进行用户认证,但是,我希望注册,登录和测试版代码输入页面,以使其布局被称为beta,而不是其余页面的应用程序(默认)布局。 / p>

我通常只是更改控制器中的布局,但没有使用Devise的控制器。
这是不可能的,我只需要更改应用程序布局,并为所有其他页面设置一个特定的布局?

解决方案

p>有控制器在设计,它们很容易定制。只需执行以下操作:



app / controllers / sessions_controller.rb

  class Users :: SessionsController< Devise :: SessionsController 
布局beta
end

config / routes.rb

  devise_for:users,:controllers => {:sessions => users / sessions} 

同样的注册和所有其他您想要拥有的页面这个布局。


I'm using devise for user auth, however, I want the registration, login, and beta code enter pages to have a layout called 'beta' not the application (default) layout that the rest of the pages have.

I normally just change the layout in the controller but there aren't controllers with Devise. Is this not possible and I just have to change the application layout and have a specific layout for all other pages?

解决方案

There are controllers in devise and they are easy to customize. Just do the following:

app/controllers/sessions_controller.rb

class Users::SessionsController < Devise::SessionsController
  layout  "beta"
end

/config/routes.rb

devise_for :users, :controllers => { :sessions => "users/sessions" }

And do the same for registration and all other pages that you want to have this layout.

这篇关于将布局与Devise集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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