tabaluga
tabaluga

Reputation: 1417

How do I store additional Data in an authlogic session?

I am using authlogic in my rails app.

my session controller looks like this

def create
    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      ...
    else
      render :action => 'new'
    end
  end

Now, I want to store additional data in the session, e.g.

@user_session.new_projects_count = Projects.all_new_since(current_user.last_login_at).count

This doesn't work, any tips?

I also wanted to increment/decrement @user_session.new_projects_count in another controller

Upvotes: 0

Views: 325

Answers (1)

Scott Watermasysk
Scott Watermasysk

Reputation: 652

I would recommend keeping authlogic as simple as possible (ie, don't add to it).

Once a user is logged in (after @user_session.save) you can then place any related information directly into session on your own.

If you want quick access to it, when you let up current_user you can always pull it at that time.

Upvotes: 1

Related Questions