Module: ActiveRecord::Calculations::ClassMethods

Defined in:
lib/fake_arel/calculations.rb

Instance Method Summary collapse

Instance Method Details

#calculate_with_fakearel(operation, column_name, options = {}) ⇒ Object

fix calculations to consider scoped :group



5
6
7
8
9
10
11
# File 'lib/fake_arel/calculations.rb', line 5

def calculate_with_fakearel(operation, column_name, options = {})
  cur_scope = scope(:find)
  if !options[:group] && cur_scope && cur_scope[:group]
    options = options.reverse_merge(cur_scope.slice(:group, :having))
  end
  calculate_without_fakearel(operation, column_name, options)
end