我试图根据传递的不同信息仅显示表中的某些记录,如果不满足任何要求,它将重定向到主页。代码一切正常,只是想看看其他人会如何解决这个问题
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