diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-07-23 14:43:17 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-07-23 14:43:32 -0700 |
commit | f38b5444428f418c4e6377bbb40d7518ea0c61a7 (patch) | |
tree | 21da7b1c7752c31f17fefb1ef6635e221ed8ec78 /activerecord/lib/active_record/associations | |
parent | b017562382e1c43655eec3456d2a78c1d4407952 (diff) | |
download | rails-f38b5444428f418c4e6377bbb40d7518ea0c61a7.tar.gz rails-f38b5444428f418c4e6377bbb40d7518ea0c61a7.tar.bz2 rails-f38b5444428f418c4e6377bbb40d7518ea0c61a7.zip |
add a specific factory method rather than using new
Diffstat (limited to 'activerecord/lib/active_record/associations')
4 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index 338d5d2afe..67d24b35d1 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -117,7 +117,7 @@ module ActiveRecord # Can be overridden (i.e. in ThroughAssociation) to merge in other scopes (i.e. the # through association's scope) def target_scope - AssociationRelation.new(klass, klass.arel_table, self).merge!(klass.all) + AssociationRelation.create(klass, klass.arel_table, self).merge!(klass.all) end # Loads the \target if needed and returns it. diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 6ddbd4955d..b4047b08bc 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -34,7 +34,7 @@ module ActiveRecord reload end - @proxy ||= CollectionProxy.new(klass, self) + @proxy ||= CollectionProxy.create(klass, self) end # Implements the writer method, e.g. foo.items= for Foo.has_many :items diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index 8c528af399..58fc00d811 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -105,13 +105,13 @@ module ActiveRecord if item.is_a?(Relation) item else - ActiveRecord::Relation.new(klass, table).instance_exec(self, &item) + ActiveRecord::Relation.create(klass, table).instance_exec(self, &item) end end if reflection.type scope_chain_items << - ActiveRecord::Relation.new(klass, table) + ActiveRecord::Relation.create(klass, table) .where(reflection.type => foreign_klass.base_class.name) end diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb index 82bf426b22..2317e34bc0 100644 --- a/activerecord/lib/active_record/associations/preloader.rb +++ b/activerecord/lib/active_record/associations/preloader.rb @@ -85,7 +85,7 @@ module ActiveRecord def initialize(records, associations, preload_scope = nil) @records = Array.wrap(records).compact.uniq @associations = Array.wrap(associations) - @preload_scope = preload_scope || Relation.new(nil, nil) + @preload_scope = preload_scope || Relation.create(nil, nil) end def run |