Displaying 1 result from an estimated 1 matches for "calculate_by_sql".
2006 Jul 27
5
Calculate methods on attr_accessor objects
Is it possible to use the calculate methods (sum, etc.) on attr_accessor
attributes?
Ie:
Class Item < ActiveRecord::Base
attr_accessor :total_cost
def total_cost
@total_cost = self.cost_unit * self.amount
end
calling Item.sum(:total_cost) or Item.sum(''total_cost'') both return a
unknown column ''total_cost'' mysql error.
I thought that active