views:

11

answers:

2

I'm trying to remove dollar signs and commas from my form input (for example, $1,000.00 => 1000.00)

I have the following following line in my before_validation method in my model:

self.parents_mortgage = self.parents_mortgage.to_s.gsub!('$,','').to_i

This is causing any number to be put through to zero out. Is there something wrong with my syntax?

A: 

use tr:

self.parents_mortgage = self.parents_mortgage.to_s.tr!('$,','').to_i
zed_0xff
A: 
self.parents_mortgage = self.parents_mortgage.to_s.gsub!('$','').gsub!(',','').to_i
Salil