Devise继续在默认的views/layouts/application.html.erb
布局中呈现它的登录表单,但我希望它使用Administrate布局,我该如何实现?
In your particular case this applies:
To have Devise use a separate layout to the rest of your application, you could do something like this:
class ApplicationController < ActionController::Base
layout :layout_by_resource
protected
def layout_by_resource
if devise_controller?
"layout_name_for_devise"
else
"application"
end
end
end
SOURCE : https://github.com/plataformatec/devise/wiki/How-To:-Create-custom-layouts
Solution-1:
Overide devise SessionsController
with your custom session controller and set layout: :adminstrator
Solution-2
In ApplicationController
:
layout: custom_layout
def custom_layout
params[:controller] == "sessions" ? "adminstrator" : "application"
end
Hope it helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.