Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Chamnap's Profile

GitHub User: chamnap

Site: chamnapchhorn.blogspot.com

Comments by Chamnap

Avatar

Can anyone explain why we have to do this so that it's threadsafe?

ruby
def self.current_id=(id)
  Thread.current[:tenant_id] = id
end

def self.current_id
  Thread.current[:tenant_id]
end

How about this?

ruby
def self.current_id=(id)
  @tenent_id = id
end

def self.current_id
  @tenent_id
end