开发者

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 开发者_StackOverflow中文版: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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜