2017-07-25 63 views

回答

3

您可以在before_action

class ApplicationController << ActionController::Base 

    before_action :check_expiration 

    def check_expiration 
    if current_user && current_user.status == 'trial' 
     if Date.today - current_user.created_at.to_date > 14 
     flash[:error] = "Your trial has expired!" 
     sign_out current_user 
     redirect_to :new_session_path 
     end 
    end 
    end 

end 
+0

尼斯一個測試到期,謝謝! – Cojones

相關問題