Forum: Ruby on Rails Formatting in form helpers

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.
stevemolitor (Guest)
on 2006-06-12 23:46
Sorry if this is a FAQ but I couldn't find anything on it:

I want to display a number in an input text_field.  I want it to display
with commas, i.e. '10,000'.  I also want to allow the user to enter
commas in the field.  It's a Float property in the model (could be a
Fixnum instead).  If the user enters an invalid number in the form (i.e.
'a345') I want to preserve the user's input and display an error.

What's the best way to go about this?  Do I do my conversions in the
controller?  Do I add accessor methods in the model that get and set
strings?  (That doesn't seem very MVC-ish.)


This topic is locked and can not be replied to.