Chris Booth
unread,May 7, 2009, 3:13:25 PM5/7/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Orlando Ruby Users Group Discussion
I'm probably making this more complicated than it needs to be, but I'm
stumped.
I have a form with a regular text box for the user to enter a dollar
amount in. The model field for that box is a decimal. The model has
a validates_numericality_of for that field. If the user types
'$1,000.00' into the field and submits, the value gets put in as 0.
I've tried stripping the $ and , in a before_validation method using
self.<field>.to_s.gsub!('$',''), but this doesn't work, because
self.<field> is already set to 0 at this point.
Where would I strip the $ and , out of the value so that it will pass
the validates_numericality_of? Or should I even be using that
validation?
--Chris