Skip to content

Commit ee6b607

Browse files
author
Marcel Molina
committed
Document how the :include option can be used in Calculations::calculate. Closes #7446 [adamwiggins, ultimoamore]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8306 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
1 parent aa9ed40 commit ee6b607

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

activerecord/CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*SVN*
22

3+
* Document how the :include option can be used in Calculations::calculate. Closes #7446 [adamwiggins, ultimoamore]
4+
35
* Fix typo in documentation for polymorphic associations w/STI. Closes #7461 [johnjosephbachir]
46

57
* Reveal that the type option in migrations can be any supported column type for your database but also include caveat about agnosticism. Closes #7531 [adamwiggins, mikong]

activerecord/lib/active_record/calculations.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module ClassMethods
2020
# If the value is a string, then the records will be returned read-only since they will have attributes that do not correspond to the table's columns.
2121
# Pass :readonly => false to override.
2222
# See adding joins for associations under Associations.
23+
#
2324
# * <tt>:include</tt>: Named associations that should be loaded alongside using LEFT OUTER JOINs. The symbols named refer
2425
# to already defined associations. When using named associations, count returns the number of DISTINCT items for the model you're counting.
2526
# See eager loading under Associations.
@@ -98,6 +99,7 @@ def sum(column_name, options = {})
9899
#
99100
# Options:
100101
# * <tt>:conditions</tt> - An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro.
102+
# * <tt>:include</tt>: Eager loading, see Associations for details. Since calculations don't load anything, the purpose of this is to access fields on joined tables in your conditions, order, or group clauses.
101103
# * <tt>:joins</tt> - An SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id". (Rarely needed).
102104
# The records will be returned read-only since they will have attributes that do not correspond to the table's columns.
103105
# * <tt>:order</tt> - An SQL fragment like "created_at DESC, name" (really only used with GROUP BY calculations).

0 commit comments

Comments
 (0)