class Users::RegistrationsController < Devise::RegistrationsController
  layout "guest"

  before_action :set_application_layout!, only: %i(edit update)
  before_action :configure_permitted_parameters

  private
    def set_application_layout!
      self.class.layout 'application'
    end

  protected
    # The path used after sign up for inactive accounts.
    def after_inactive_sign_up_path_for(resource)
      super(resource)
      :new_user_session
    end

    def configure_permitted_parameters
      devise_parameter_sanitizer.permit(:sign_up, keys: %i(time_zone))
      devise_parameter_sanitizer.permit(:account_update, keys: %i(time_zone))
    end
end

class Users::RegistrationsController < Devise::RegistrationsController
  layout :action_layout
  before_action :configure_permitted_parameters

  private
    def action_layout
      case action_name
      when 'edit', 'update' then 'application'
      else 'guest'
      end
    end

  protected
    # The path used after sign up for inactive accounts.
    def after_inactive_sign_up_path_for(resource)
      super(resource)
      :new_user_session
    end

    def configure_permitted_parameters
      devise_parameter_sanitizer.permit(:sign_up, keys: %i(time_zone))
      devise_parameter_sanitizer.permit(:account_update, keys: %i(time_zone))
    end
end

Fix error on signup page visits
Fix error on signup page visits

Users were getting errors when visiting the signup page. It seems
that clicking around in the "guest area" (e.g. forgot my password
page) would cause the layout to be set to the application layout
which would then error because it was trying to load the user record
and use its email address for the sidebar.
