Rails & Devise: How to render login page without a layout?

后端 未结 3 1200
再見小時候
再見小時候 2021-01-30 01:11

I know this is probably a simple question, but I\'m still trying to figure Devise out...

I want to render :layout => false on my login page; how can I do

3条回答
  •  灰色年华
    2021-01-30 01:42

    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

提交回复
热议问题