Module: ActiveRecord::Tenanted::Storage::Blob

Defined in:
lib/active_record/tenanted/storage.rb

Instance Method Summary collapse

Instance Method Details

#keyObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/active_record/tenanted/storage.rb', line 49

def key
  self[:key] ||= if klass = ActiveRecord::Tenanted.connection_class
    unless tenant = klass.current_tenant
      raise NoTenantError, "Cannot generate a Blob key without a tenant"
    end

    token = self.class.generate_unique_secure_token(length: ActiveStorage::Blob::MINIMUM_TOKEN_LENGTH)
    [ tenant, token ].join("/")
  else
    super
  end
end