Sha256: 93e86663be5c3750ed745993896a653aaf2f5a4246cbe9e768aaaf9af3578082

Contents?: true

Size: 683 Bytes

Versions: 33

Compression:

Stored size: 683 Bytes

Contents

module ActiveRecord
  class AssociationRelation < Relation
    def initialize(klass, table, association)
      super(klass, table)
      @association = association
    end

    def proxy_association
      @association
    end

    def ==(other)
      other == to_a
    end

    def build(*args, &block)
      scoping { @association.build(*args, &block) }
    end
    alias new build

    def create(*args, &block)
      scoping { @association.create(*args, &block) }
    end

    def create!(*args, &block)
      scoping { @association.create!(*args, &block) }
    end

    private

    def exec_queries
      super.each { |r| @association.set_inverse_instance r }
    end
  end
end

Version data entries

33 entries across 33 versions & 6 rubygems

Version Path
activerecord-4.2.11.3 lib/active_record/association_relation.rb
activerecord-4.2.11.2 lib/active_record/association_relation.rb
activerecord-4.2.11.1 lib/active_record/association_relation.rb
activerecord-4.2.11 lib/active_record/association_relation.rb
activerecord-4.2.10 lib/active_record/association_relation.rb
activerecord-4.2.10.rc1 lib/active_record/association_relation.rb
activerecord-4.2.9 lib/active_record/association_relation.rb
activerecord-4.2.9.rc2 lib/active_record/association_relation.rb
activerecord-4.2.9.rc1 lib/active_record/association_relation.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activerecord-4.2.8/lib/active_record/association_relation.rb
activerecord-4.2.8 lib/active_record/association_relation.rb
activerecord-4.2.8.rc1 lib/active_record/association_relation.rb
activerecord-4.2.7.1 lib/active_record/association_relation.rb
activerecord-4.2.7 lib/active_record/association_relation.rb
activerecord-4.2.7.rc1 lib/active_record/association_relation.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/association_relation.rb
activerecord-4.2.6 lib/active_record/association_relation.rb
activerecord-4.2.6.rc1 lib/active_record/association_relation.rb
activerecord-4.2.5.2 lib/active_record/association_relation.rb
activerecord-4.2.5.1 lib/active_record/association_relation.rb