im attempting to only display certain records from a table based on different information passed through, and if none of the requirements are met it redirects to home. the code is all functioning, just wanted to see how other would have tackled this
if current_user.admin?
@schedules = Schedule.all
elsif current_user.team_id?
@schedules = Schedule.find_all_by_team_id(current_user[:team_id])
else
redirect_to root_path, :status => 301, :alert => "Please contact your club administrator to be assigned to a team."
return
end
You should always move complex logic away from your controllers.
in your controller: