diff options
author | Oscar Del Ben <oscar@oscardelben.com> | 2012-07-07 10:20:22 -0700 |
---|---|---|
committer | Oscar Del Ben <oscar@oscardelben.com> | 2012-07-07 10:20:22 -0700 |
commit | 91c8d91536b1f41f0c4518e67b4bf31b1ef4f109 (patch) | |
tree | bb78427cd969be2e0ae19ddcb888a77f9825b327 /activerecord/lib/active_record | |
parent | ee20be7c33538e6e9d334ddbd16d427190c7ff00 (diff) | |
download | rails-91c8d91536b1f41f0c4518e67b4bf31b1ef4f109.tar.gz rails-91c8d91536b1f41f0c4518e67b4bf31b1ef4f109.tar.bz2 rails-91c8d91536b1f41f0c4518e67b4bf31b1ef4f109.zip |
Add docs for eager_laod and preload
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index e401ed37b0..74ffa09c85 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -63,6 +63,12 @@ module ActiveRecord self end + # Forces eager loading by performing a LEFT OUTER JOIN on +args+: + # + # User.eager_load(:posts) + # => SELECT "users"."id" AS t0_r0, "users"."name" AS t0_r1, ... + # FROM "users" LEFT OUTER JOIN "posts" ON "posts"."user_id" = + # "users"."id" def eager_load(*args) args.blank? ? self : spawn.eager_load!(*args) end @@ -72,6 +78,10 @@ module ActiveRecord self end + # Allows preloading of +args+, in the same way that +includes+ does: + # + # User.preload(:posts) + # => SELECT "posts".* FROM "posts" WHERE "posts"."user_id" IN (1, 2, 3) def preload(*args) args.blank? ? self : spawn.preload!(*args) end |