Assume a query of the following form
operatingExpenses = Expense.find(:all,
{:select=>\"categories.activityType, categories.name heading, sum(amount
Active record is trying to return "Expense" objects built from the results of your query. But expense objects don't have a totalAmount field, so this is unrequested "bonus data" as far as ActiveRecord can tell. It coud just throw it out, but instead it keeps it for you, with the most forgiving type assumptions it can.
My suggestions:
amount so ActiveRecord knows what to do with it.If you must have the total as its own field, add an accessor in your Expense model like so:
def total_amount
totalAmount.to_f
end
and use it like so: operatingExpenses[1].total_amount in your code.