diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-10-09 22:00:33 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-10-09 22:00:33 +0100 |
commit | ab5a9335020eff0da35b62b86a62ed8587a4d598 (patch) | |
tree | 1a1996c8844e359b88d5b30bf3531d22dba83d1b /activerecord/lib/active_record/associations/through_association_scope.rb | |
parent | c954d54e2f36bb53ced5e3655adc071dd233797e (diff) | |
download | rails-ab5a9335020eff0da35b62b86a62ed8587a4d598.tar.gz rails-ab5a9335020eff0da35b62b86a62ed8587a4d598.tar.bz2 rails-ab5a9335020eff0da35b62b86a62ed8587a4d598.zip |
Add support for nested through associations in JoinAssociation. Hence Foo.joins(:bar) will work for through associations. There is some duplicated code now, which will be refactored.
Diffstat (limited to 'activerecord/lib/active_record/associations/through_association_scope.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/through_association_scope.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/through_association_scope.rb b/activerecord/lib/active_record/associations/through_association_scope.rb index 90ebadda89..8406f5fd20 100644 --- a/activerecord/lib/active_record/associations/through_association_scope.rb +++ b/activerecord/lib/active_record/associations/through_association_scope.rb @@ -73,6 +73,8 @@ module ActiveRecord if left.options[:as] polymorphic_join = "AND %s.%s = %s" % [ table_aliases[left], "#{left.options[:as]}_type", + # TODO: Why right.klass.name? Rather than left.active_record.name? + # TODO: Also should maybe use the base_class (see related code in JoinAssociation) @owner.class.quote_value(right.klass.name) ] end @@ -117,6 +119,8 @@ module ActiveRecord joins.join(" ") end + # TODO: Use the same aliasing strategy (and code?) as JoinAssociation (as this is the + # documented behaviour) def table_aliases @table_aliases ||= begin tally = {} |