aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-12-28 03:49:35 +0530
committerPratik Naik <pratiknaik@gmail.com>2009-12-28 03:59:44 +0530
commit6a776dcc9df437c0bcc3c1ff1d2a79966264bac9 (patch)
tree46932debde94297b0e3e5e0c1dad48321b35e1cf /activerecord/lib/active_record/associations.rb
parent9521fcbcc295cb1dd34f7d458c40790466a55244 (diff)
downloadrails-6a776dcc9df437c0bcc3c1ff1d2a79966264bac9.tar.gz
rails-6a776dcc9df437c0bcc3c1ff1d2a79966264bac9.tar.bz2
rails-6a776dcc9df437c0bcc3c1ff1d2a79966264bac9.zip
Use relation.from when constructing a relation
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 2735bc5141..c23c9f63f1 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1707,7 +1707,7 @@ module ActiveRecord
def construct_finder_arel_with_included_associations(options, join_dependency)
scope = scope(:find)
- relation = arel_table((scope && scope[:from]) || options[:from])
+ relation = arel_table
for association in join_dependency.join_associations
relation = association.join_relation(relation)
@@ -1717,7 +1717,8 @@ module ActiveRecord
select(column_aliases(join_dependency)).
group(construct_group(options[:group], options[:having], scope)).
order(construct_order(options[:order], scope)).
- where(construct_conditions(options[:conditions], scope))
+ where(construct_conditions(options[:conditions], scope)).
+ from((scope && scope[:from]) || options[:from])
relation = relation.where(construct_arel_limited_ids_condition(options, join_dependency)) if !using_limitable_reflections?(join_dependency.reflections) && ((scope && scope[:limit]) || options[:limit])
relation = relation.limit(construct_limit(options[:limit], scope)) if using_limitable_reflections?(join_dependency.reflections)