module Switchman::ActiveRecord::ForeignAssociation

Public Instance Methods

set_owner_attributes(record) click to toggle source

significant change:

* transpose the key to the correct shard
# File lib/switchman/active_record/association.rb, line 62
def set_owner_attributes(record) # rubocop:disable Naming/AccessorMethodName
  return if options[:through]

  key = owner._read_attribute(reflection.join_foreign_key)
  key = Shard.relative_id_for(key, owner.shard, shard)
  record._write_attribute(reflection.join_primary_key, key)

  record._write_attribute(reflection.type, owner.class.polymorphic_name) if reflection.type
end