stevemolitor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Nov-05 22:22 UTC
Saving form data with currency symbols / validating custom formats
I''m trying to display a numeric attribute of a model as a currency on a form, and then save the user''s input. So the text field might display ''$9.98'' and the user is allowed to enter dollar signs. How can I remove the dollar sign before saving to the db and still display the user''s original input string in error messages? My template file looks like this: <%= text_field("winning[]", "amount", :value => number_to_currency(@winning.amount) %> I tried manually removing the dollar signs from the values in the params hash before applying them to the models (via update_attributes) but then the models don''t have the user''s original inputs, and I''m using the error_messages_for tag to display the errors. I was also trying to avoid hacking presentation format knowledge into the model object if possible. Any ideas? Thanks! Steve --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---