aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/collection_proxy.rb10
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb2
2 files changed, 2 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb
index adfc71d435..81b4a26b04 100644
--- a/activerecord/lib/active_record/associations/collection_proxy.rb
+++ b/activerecord/lib/active_record/associations/collection_proxy.rb
@@ -56,6 +56,8 @@ module ActiveRecord
Array.wrap(association.options[:extend]).each { |ext| proxy_extend(ext) }
end
+ alias_method :new, :build
+
def respond_to?(*args)
super ||
(load_target && target.respond_to?(*args)) ||
@@ -115,14 +117,6 @@ module ActiveRecord
@association.reload
self
end
-
- def new(*args, &block)
- if @association.is_a?(HasManyThroughAssociation)
- @association.build(*args, &block)
- else
- method_missing(:new, *args, &block)
- end
- end
end
end
end
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb
index 280688be52..2e818dca5d 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -6,8 +6,6 @@ module ActiveRecord
class HasManyThroughAssociation < HasManyAssociation #:nodoc:
include ThroughAssociation
- alias_method :new, :build
-
# Returns the size of the collection by executing a SELECT COUNT(*) query if the collection hasn't been
# loaded and calling collection.size if it has. If it's more likely than not that the collection does
# have a size larger than zero, and you need to fetch that collection afterwards, it'll take one fewer