List all active login / user sessions?

I use Authlogic for authentication in my application with all default settings. I want to know if there is a way to list all registered users on the site, stop their sessions, etc. Basically, this will be the "index" method for my user_sessions controller.

Here is what I have tried so far.

In my user_sessions_controller.rb file .....

def index
  @user_sessions = UserSession.all
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @user_sessions }
    end
end

What fails with ....

undefined `all 'method for UserSession: Class

error message.

Is there a way to list all current user sessions for the entire site?

~ Dan

+3
source share
1 answer

Try this built-in version from authlogic

User.logged_in
+3

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


All Articles