diff options
author | Josh Kalderimis <josh.kalderimis@gmail.com> | 2011-06-01 00:42:02 +0200 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-06-01 00:01:35 +0100 |
commit | eb7ef2ccd618bc87451b980722ec73ee41c203a1 (patch) | |
tree | 72cc2db8eaa60a5bd5be48b70dbe0cedfed89f81 /activerecord/lib/active_record | |
parent | 1f34a79373854e36c7bf77ffa70688cda6d27a5c (diff) | |
download | rails-eb7ef2ccd618bc87451b980722ec73ee41c203a1.tar.gz rails-eb7ef2ccd618bc87451b980722ec73ee41c203a1.tar.bz2 rails-eb7ef2ccd618bc87451b980722ec73ee41c203a1.zip |
added an alias for new to build to the AR collection proxy, this corrects an issue where the collection proxies were not consistent
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 10 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_through_association.rb | 2 |
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 |