Current.user from Active Records example

I can’t understand this snippet from (the example model):

class Article < ApplicationRecord
  belongs_to :author, default: -> { Current.user }

who is Current.user? How it works? Can you point me to relevant docs?

thank you,


Here’s a writeup: Rails Current Attributes: Usage, Pros and Cons - Mintbit

It’s a way to have attribute sharing across different contexts. I believe it will even work if the app is running across multiple servers in a sharded deployment setup. It is also thread-safe.


1 Like

holy craps! Big stuff! Thank you so much,