Just off the top of my head and never done it but... could you reuse the params value to repopulate the field if the field has errors? I think it should be possible. Something like:
unless @your_object.save @your_object.your_attribute = params[:your_object][:your_attribute] if @your_object.errors.on @your_object.your_attribute render... end The syntax might be off but you should get it right easily if that's the case. On Sep 14, 11:05 am, jdc <[email protected]> wrote: > I've noticed that if I use the numericality validator and the user > enters, for example "1234ABCD" it'll come back with a "not a number" > error, but it then fills the input box with "1234", discarding the non- > numeric input the user originally put in. > > I've seen a similar question about this in this group, but the poster > was looking for a way to completely blank the number upon return. I > want something different - I'd like the original value to be > displayed, which seems more logical to me. > > What worries me about having it auto-strip the non-numeric stuff is, > if a user has a couple of validation problems in the form, they may > fix other ones, not noticing the numeric, which will now happily post > because it's been turned into a number automagically by Rails - and > maybe not the number that was intended. > > I'm afraid it may be impossible since I think it's actually the input > parser doing this and not the validator, but does anyone know how to > make the original value come back instead of the parsed? > > Thanks in advance. > > jc -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

