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