You can subclass the controller and configure the router to use that:
class SessionsController < Devise::SessionsController
layout false
end
And in config/routes.rb
:
devise_for :users, :controllers => { :sessions => "sessions" }
You need to move the session views to this controller too.
OR make a method in app/controllers/application_controller.rb
:
class ApplicationController < ActionController::Base
layout :layout
private
def layout
# only turn it off for login pages:
is_a?(Devise::SessionsController) ? false : "application"
# or turn layout off for every devise controller:
devise_controller? && "application"
end
end
You can also create a sessions.html.erb file in app/views/layouts/devise. That layout will then be used for just the sign in screen.
By using the devise_controller? helper you can determine when a Devise controller is active and respond accordingly. 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?
"devise"
else
"application"
end
end
end
create a devise.html.erb file in your views/layouts
So if its a device controller will render the devise layout else the application layout
from: https://github.com/plataformatec/devise/wiki/How-To:-Create-custom-layouts
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.