module Switchman::ActiveRecord::CollectionAssociation

Public Instance Methods

_create_record(*) click to toggle source
Calls superclass method
# File lib/switchman/active_record/association.rb, line 34
def _create_record(*)
  shard.activate { super }
end
find_target() click to toggle source
Calls superclass method
# File lib/switchman/active_record/association.rb, line 25
def find_target
  shards = reflection.options[:multishard] && owner.respond_to?(:associated_shards) ? owner.associated_shards : [shard]
  # activate both the owner and the target's shard category, so that Reflection#join_id_for,
  # when called for the owner, will be returned relative to shard the query will execute on
  Shard.with_each_shard(shards, [klass.connection_classes, owner.class.connection_classes].uniq) do
    super
  end
end