I have code similar to:
number_to_currency(line_item.price, :unit => "£")
littering my views in various models. Since my application deals only in GBP (£), should I not move this into each of my models so that line_item.price
returns the string as it should be (i.e. number_to_currency(line_item.price, :unit => "£")
and line_item.price
are the same. I'm thinking that to do this I should:
def price
number_to_currency(self.price, :unit => "£")
end
but this doesn't work. If price
is already defined in the model, then Rails reports 'stack level too deep', when I change def price
to def amount
, then it complains that number_to_currency
is not defined?