Is there a way to customise sorcery's require_login
function to provide a flash message and to redirect to page other than root_path e.g. to a login page?
This can be done by overriding sorcery's not_authenticated function, which it calls when the user is not logged in, for example
class ApplicationController < ActionController::Base
before_action :require_login
def not_authenticated
flash[:alert] = 'Customised warning'
redirect_to main_app.login_path
end
end
Also make sure that the rails_admin controllers are inheriting from your application controller;
RailsAdmin.config do |config| ... config.parent_controller = 'ApplicationController' end