ActiveRecordStore: cleanup & avoiding duplication

Hi,

I'm using ActiveRecordStore to track user sessions.
I've used as a base the next sources:

- http://blog.levicole.com/articles/category/ror
- http://matt-beedle.com/2006/12/13/rails-how-to-find-out-who-is-online/
- http://www.williambharding.com/blog/?p=99

This is what I currently do:

IN SESSION CONTROLLER

def create
  self.current_user = User.authenticate(params[:login],
params[:password])
  if logged_in?
    session.model.user_id = current_user.id

    if params[:remember_me] == "1"
      self.current_user.remember_me
    end

    current_user.update_attribute(:online, true)
    redirect_back_or_default('/')

  else
    render :action => 'new'
  end
end

def destroy
  self.current_user.forget_me if logged_in?
  reset_session
  current_user.update_attribute(:online, false)
  redirect_back_or_default('/')
end

FINDING SESSIONS

@online_sessions = CGI::Session::ActiveRecordStore::Session.find( :all,
:conditions => [ "updated_at > ? and user_id is not null", Time.now() -
10.minutes ], :limit => 50 )