diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-08-03 17:26:59 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-08-12 13:10:58 -0300 |
commit | 6ed1ba472e0f649726d9a0d04056934d1afe4573 (patch) | |
tree | 230bd8d92661a0dfe633c4a8549975744f1f2243 /activerecord/lib/active_record | |
parent | 4134d7db34506887f5cb945bb4e51c53c5f67ec3 (diff) | |
download | rails-6ed1ba472e0f649726d9a0d04056934d1afe4573.tar.gz rails-6ed1ba472e0f649726d9a0d04056934d1afe4573.tar.bz2 rails-6ed1ba472e0f649726d9a0d04056934d1afe4573.zip |
Ensure we can nest include calls [#5285 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/spawn_methods.rb | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index cd6c6f8d1f..0bf0b37900 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -11,7 +11,7 @@ module ActiveRecord def includes(*args) args.reject! { |a| a.blank? } - clone.tap {|r| r.includes_values += args if args.present? } + clone.tap {|r| r.includes_values = (r.includes_values + args).flatten.uniq if args.present? } end def eager_load(*args) diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb index 02db8d2b89..f857e50dea 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -8,7 +8,13 @@ module ActiveRecord ((Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS) - [:joins, :where]).each do |method| value = r.send(:"#{method}_values") - merged_relation.send(:"#{method}_values=", value) if value.present? + if value.present? + if method == :includes + merged_relation = merged_relation.includes(value) + else + merged_relation.send(:"#{method}_values=", value) + end + end end merged_relation = merged_relation.joins(r.joins_values) |