diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-02 23:09:40 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-02 23:23:35 -0300 |
commit | 5d26c8f00a11e40660be7516a13512ed522863ed (patch) | |
tree | b8954479f19d5a9ad3fdb44d4f0d0f7ce11a5d54 /activerecord/lib | |
parent | 36720af42995c8bac06ea7187e2c5768f89c2783 (diff) | |
download | rails-5d26c8f00a11e40660be7516a13512ed522863ed.tar.gz rails-5d26c8f00a11e40660be7516a13512ed522863ed.tar.bz2 rails-5d26c8f00a11e40660be7516a13512ed522863ed.zip |
Fix issue with private kernel methods and collection associations. Closes #2508
Change CollectionProxy#method_missing to use scoped.public_send, to
avoid a problem described in issue #2508 when trying to use class
methods with names like "open", that clash with private kernel methods.
Also changed the dynamic matcher instantiator to send straight to
scoped, to avoid another roundtrip to method_missing.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index ad029d1101..50d16b16a9 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -81,7 +81,7 @@ module ActiveRecord def method_missing(method, *args, &block) match = DynamicFinderMatch.match(method) if match && match.instantiator? - send(:find_or_instantiator_by_attributes, match, match.attribute_names, *args) do |r| + scoped.send(:find_or_instantiator_by_attributes, match, match.attribute_names, *args) do |r| proxy_association.send :set_owner_attributes, r proxy_association.send :add_to_target, r yield(r) if block_given? @@ -101,7 +101,7 @@ module ActiveRecord end else - scoped.readonly(nil).send(method, *args, &block) + scoped.readonly(nil).public_send(method, *args, &block) end end |