6
我有一个应用程序,用户的会员资格已过期。强制用户在设计中注销
我正在设置一个before_filter
在我的applications.rb
文件中,以检查它们是否在网站中成为活动成员之前处于活动状态。
在我的application.rb中的文件:
before_filter :check_account
def check_account
if user_signed_in?
if current_user.account.expired
flash[:error] = "Your account is expired. Please contact Navanti for renewal."
redirect_to destroy_user_session_path
end
end
end
我不断收到重定向循环错误。我猜这是因为被称为的注销页面也在做before_filter
,但是如果我把except => [:users => :sign_out]
它仍然会引发循环错误。
感谢您的帮助。
要求设计方法:
# DELETE /resource/sign_out
def destroy
redirect_path = after_sign_out_path_for(resource_name)
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
set_flash_message :notice, :signed_out if signed_out && is_navigational_format?
# We actually need to hardcode this as Rails default responder doesn't
# support returning empty response on GET request
respond_to do |format|
format.any(*navigational_formats) { redirect_to redirect_path }
format.all do
head :no_content
end
end
end
编写destroy_user_session_path的代码。 – alex
是的PLZ在这里销毁代码 –
该代码来自Devise的宝石 - 我会尽力找到它并将其添加到问题中。 – matthewvb