Call the developer from the model

In my application, I need to write out specific users from time to time. And I need to do this from the interface or from a third-party worker. Therefore, I would like to create a method sign_outin my model user.

I saw in the documentation that develops the method sign_out, but only in the controller. Is there a way to access this method from a model or something similar.

thanks

+4
source share
1 answer

You should read this answer fooobar.com/questions/1545836 / ... first .

, User Model, expire_at_next_request? before_filter , .

class ApplicationController < ActionController::Base
  before_filter :logout_if_requested

  def logout_if_requested
    if current_user && current_user.expire_at_next_request?
      current_user.update_attributes(:expire_at_next_request=>false)
      sign_out current_user
      redirect_to :new_session_path
    end
  end
+3

Source: https://habr.com/ru/post/1625332/


All Articles