How to log user_name in Rails?

后端 未结 12 1712
遇见更好的自我
遇见更好的自我 2020-12-15 06:52

I use Devise in Rails 3. I want to see name of current_user in production.log.

I would like to configure rails like this:

config.log_tags = [:user_na         


        
12条回答
  •  忘掉有多难
    2020-12-15 07:35

    For anyone using Redis::Store @fjuillen's answer looks like this:

    redis = Redis::Store.new
    redis.select 3 # only if you use a different database
    result = redis.get req.cookie_jar["_session_id"]
    

    tested on rails 4.

提交回复
热议问题