ユーザーが期限切れのメンバーシップを持っているアプリがあります。
私は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