Here is a method I have in my ApplicationController
, but it's "ugly" and needs some cleanup.
def user_root_path
return root_url unless user_signed_in?
return admin_root_url if current_user.admin?
return contributor_dashboard_url if current_user.athlete_contributor? && !current_user.class.name.eql?("Athlete")
return school_admin_athletes_path if current_user.role?("School Admin")
case current_user.class.name
when "Athlete"
if current_user.username.present?
edit_vitals_athlete_profile_path
else
account_finalize_path
end
when "HighSchoolCoach"
school_admin_athletes_path
when "CollegeCoach"
if current_user.sports.blank? || current_user.college_id.blank?
account_finalize_path
else
search_index_path
end
else
root_url
end
end