How to access current tenant in model when using Apartment gem

Solid Source

Apartment::Tenant.current is method that returns the current tenant name. But When being used in models I have noticed that behavior is not consistent, sometimes it returns correct tenant, sometime "public".

Is there is any specific way to access it?

BTW. I am trying to use in the custom path for paperclip with s3 .

class Media
   has_attached_file :file,
                       :storage => :s3,
                       :s3_credentials => {
                         :access_key_id => "Access Key",
                         :secret_access_key => "Secrete Key"
                       :path => "#{Apartment::Tenant.current}/:class/:attachment/:id_partition/:style/:filename"



comments powered by Disqus