def login_required
unless current_user
store_location
flash[:notice] = I18n.t('must_be_logged_in')
redirect_to new_user_session_path
return false
end
end
我在 Rails 应用程序中有这种方法。我的问题是该线路何时return false
运行?
它前面的行说redirect_to new_user_session_path
.
def admin_required
return false if login_required == false
unless current_user.admin?
store_location
flash[:notice] = t('must_be_admin')
redirect_to new_user_session_url
return false
end
end
为了澄清这个方法需要login_required == false
(或真)..第一个方法将如何返回假?