diff options
Diffstat (limited to 'activerecord/lib/active_record/associations/has_many_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index f5f27dc410..b04cb81a5c 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -85,6 +85,20 @@ module ActiveRecord end protected + def method_missing(method, *args, &block) + if @target.respond_to?(method) || (!@association_class.respond_to?(method) && Class.respond_to?(method)) + super + else + @association_class.constrain( + :conditions => @finder_sql, + :joins => @join_sql, + :readonly => false, + :creation => { @association_class_primary_key_name => @owner.id }) do + @association_class.send(method, *args, &block) + end + end + end + def find_target find_all end |