Ruby on rails 是否可以自动暂停Desive中的用户?

Ruby on rails 是否可以自动暂停Desive中的用户?,ruby-on-rails,devise,Ruby On Rails,Devise,有一个应用程序使用Desive,我想添加自动暂停帐户的可能性(14天试用)。我一直在寻找一些东西让Desive用户过期,但我发现的是:这对我没有什么帮助 有人知道在特定时间后自动挂起用户帐户的方法吗?您可以在before\u操作中测试过期时间 class ApplicationController << ActionController::Base before_action :check_expiration def check_expiration if cu

有一个应用程序使用Desive,我想添加自动暂停帐户的可能性(14天试用)。我一直在寻找一些东西让Desive用户过期,但我发现的是:这对我没有什么帮助


有人知道在特定时间后自动挂起用户帐户的方法吗?

您可以在before\u操作中测试过期时间

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 
类应用程序控制器14
flash[:error]=“您的试用期已过期!”
注销当前用户
重定向到:新会话路径
结束
结束
结束
结束