Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

How to redirect a user to a specific URL depending of some parameters, for example his role.

Step-by-step guide

  1. Create a new file:
    app/decorators/controllers/mno_enterprise/application_controller_decorator.rb

  2. 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) 
    url = '/admin/'
  else
    url = MnoEnterprise.router.dashboard_path || main_app.root_url
  end
  return (return_to_url(resource) || previous_url || default_url)
end

 

 

  • No labels