How to redirect user directly after login to a specific URL
How to redirect a user to a specific URL depending of some parameters, for example his role.
Step-by-step guide
Create a new file:
app/decorators/controllers/mno_enterprise/application_controller_decorator.rb
Overload the method
after_sign_in_path
For example:
def after_sign_in_path_for(resource) previous_url = session.delete(:previous_url) default_url = if resource.respond_to?(:admin_role) && resource.admin_role.present '/admin/' else MnoEnterprise.router.dashboard_path || main_app.root_url end return (return_to_url(resource) || previous_url || default_url) end