aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2015-01-03 14:58:17 +0000
committerVijay Dev <vijaydev.cse@gmail.com>2015-01-03 14:58:17 +0000
commit4b9dba99d65b1bd27576b16a68d7d18522bae9ea (patch)
tree4672dd2377a4e4ef71992c5478f2606f5d86e371 /activerecord/lib/active_record
parent02e72a49d1c99084fef2c78c3a194e03b879099d (diff)
parent7cc145ec65167084e8b05d9462eaf94534fa0168 (diff)
downloadrails-4b9dba99d65b1bd27576b16a68d7d18522bae9ea.tar.gz
rails-4b9dba99d65b1bd27576b16a68d7d18522bae9ea.tar.bz2
rails-4b9dba99d65b1bd27576b16a68d7d18522bae9ea.zip
Merge branch 'master' of github.com:rails/docrails
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/querying.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/querying.rb b/activerecord/lib/active_record/querying.rb
index e8de4db3a7..91c9a0db99 100644
--- a/activerecord/lib/active_record/querying.rb
+++ b/activerecord/lib/active_record/querying.rb
@@ -55,11 +55,12 @@ module ActiveRecord
# The use of this method should be restricted to complicated SQL queries that can't be executed
# using the ActiveRecord::Calculations class methods. Look into those before using this.
#
- # ==== Parameters
+ # Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id"
+ # # => 12
#
- # * +sql+ - An SQL statement which should return a count query from the database, see the example below.
+ # ==== Parameters
#
- # Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id"
+ # * +sql+ - An SQL statement which should return a count query from the database, see the example above.
def count_by_sql(sql)
sql = sanitize_conditions(sql)
connection.select_value(sql, "#{name} Count").to_i