module Octoball::ShardedCollectionProxyCreate

Public Instance Methods

create(klass, association) click to toggle source
Calls superclass method
# File lib/octoball/association.rb, line 30
def create(klass, association)
  shard = association.owner.current_shard
  return super unless shard
  return RelationProxy.new(super, shard) if shard == ActiveRecord::Base.current_shard
  ret = nil
  ActiveRecord::Base.connected_to(shard: shard, role: Octoball.current_role) do
    ret = RelationProxy.new(super, shard)
    nil # return nil to avoid loading relation
  end
  ret
end