Forum: Ruby on Rails Number input field (stuck with whitespaces)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
6f4ff03626875d9943afa17659984261?d=identicon&s=25 Dusan (Guest)
on 2007-06-01 09:50
(Received via mailing list)

I am RoR newbee, so maybe this is stupid question, but I can't figure
it out. I have a form from which I want to get some numbers. But if
user has typed a number with whitespaces in it, I am getting only the
first part until the whitespace.

For example, if user types 300 000, the record is saved as only 300.

Can anybody help?
19990e3fa0fc68c874f42f13d1500011?d=identicon&s=25 Steve Rawlinson (trip)
on 2007-06-01 14:23
There's probably a better way to do this but here is one suggestion.
Instead of putting the return from the form into the (I presume
numerical) model method, create a dummy method which gets the input from
the form and puts it into a string. Then convert it yourself to a

number = string_from_form.gsub(/\s+/, "").to_i
This topic is locked and can not be replied to.