diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-19 11:16:12 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-19 11:16:12 +0000 |
commit | 02adc49d72152a00a93423931f767f9cdb0ef15a (patch) | |
tree | aa4adb878d5bdb0e26db3aaf0cb0c6e705b2c5dc /activerecord/lib/active_record/associations/has_many_association.rb | |
parent | ae8171ddc5886102421e356888f03d06e7bf5131 (diff) | |
download | rails-02adc49d72152a00a93423931f767f9cdb0ef15a.tar.gz rails-02adc49d72152a00a93423931f767f9cdb0ef15a.tar.bz2 rails-02adc49d72152a00a93423931f767f9cdb0ef15a.zip |
Simplify association proxy implementation by factoring construct_scope out of method_missing. Closes #6643.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5564 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations/has_many_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 0a275ab430..3ea8187cb8 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -93,26 +93,6 @@ module ActiveRecord end protected - def method_missing(method, *args, &block) - if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) - super - else - create_scoping = {} - set_belongs_to_association_for(create_scoping) - - @reflection.klass.with_scope( - :create => create_scoping, - :find => { - :conditions => @finder_sql, - :joins => @join_sql, - :readonly => false - } - ) do - @reflection.klass.send(method, *args, &block) - end - end - end - def load_target if !@owner.new_record? || foreign_key_present begin @@ -205,6 +185,12 @@ module ActiveRecord @counter_sql = @finder_sql end end + + def construct_scope + create_scoping = {} + set_belongs_to_association_for(create_scoping) + { :find => { :conditions => @finder_sql, :joins => @join_sql, :readonly => false }, :create => create_scoping } + end end end end |