aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-10-05 15:25:06 -0300
committerEmilio Tagua <miloops@gmail.com>2009-10-05 15:25:06 -0300
commit1daceeb838dccfd47547dedea67eb22e7c06c5a9 (patch)
tree506ad932a341befbbea1d4ea719d992ef22f3512 /activerecord/lib/active_record/base.rb
parent9a71b6d29d013d8ee3f0d3f408d53e1cf3c9f799 (diff)
parent65f055a3ed790d41aeca8d4ca7f3771b05cf544f (diff)
downloadrails-1daceeb838dccfd47547dedea67eb22e7c06c5a9.tar.gz
rails-1daceeb838dccfd47547dedea67eb22e7c06c5a9.tar.bz2
rails-1daceeb838dccfd47547dedea67eb22e7c06c5a9.zip
Merge branch 'associations_2'
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb19
1 files changed, 15 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index a1b6606e3e..668506c01a 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -664,11 +664,23 @@ module ActiveRecord #:nodoc:
# This is an alias for find(:all). You can pass in all the same arguments to this method as you can
# to find(:all)
def all(*args)
- if args.empty? && !scoped?(:find)
- arel_table
+ options = args.extract_options!
+
+ if options.empty? && !scoped?(:find)
+ relation = arel_table
else
- construct_finder_arel(*args)
+ relation = construct_finder_arel(options)
+ include_associations = merge_includes(scope(:find, :include), options[:include])
+
+ if include_associations.any?
+ if references_eager_loaded_tables?(options)
+ relation.eager_load(include_associations)
+ else
+ relation.preload(include_associations)
+ end
+ end
end
+ relation
end
# Executes a custom SQL query against your database and returns all the results. The results will
@@ -1719,7 +1731,6 @@ module ActiveRecord #:nodoc:
relation = relation.readonly if options[:readonly]
relation
-
end
def construct_finder_sql(options, scope = scope(:find))