I feel bad asking this question, as I thought I knew enough about Activerecord to answer this myslef. But such is the way of having SO available ...
I'm trying to remove the commas from a field in a model of mine, I want the user to be able to type a number , ie 10,000 and that number be stored in the database as 10000. I was hoping that I could do some model-side normalization to remove the comma. I don't want to depend on the view or controller to properly format my data.
I tried ;
before_validation :normalize
def normalize
self['thenumber'] = self['thenumber'].to_s.gsub(',','')
end
no worky :(