Answer the question
In order to leave comments, you need to log in
Rails routing based on user role?
Hello. How to properly redirect in Rails depending on the selected role.
Now implemented like this
in application_controller.rb
def index
redirect_root
end
def redirect_root
if current_user_type == 'Admin'
redirect_to admin_index_path
else
redirect_to institution_index_path
end
end
root 'application#index'
Answer the question
In order to leave comments, you need to log in
before_action :redirect_root, only: [:index]
def index; end
protected
def redirect_root
# ...
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question