Module: BetterAr::Calculations
- Defined in:
- lib/better_ar/calculations.rb
Instance Method Summary collapse
-
#count(column_name = nil, count_options = {}) ⇒ Integer
Does a count on the query.
Instance Method Details
#count(column_name = nil, count_options = {}) ⇒ Integer
Does a count on the query
example:
User.count(:age => 20)
is the same as:
User.where(:age => 20).count
if the key :conditions is present it will fall back to legacy
16 17 18 19 20 21 22 23 |
# File 'lib/better_ar/calculations.rb', line 16 def count(column_name = nil, = {}) if column_name.is_a?(Hash) = column_name.clone column_name = nil end all().calculate(:count, nil, {}) end |