That would be fine if no validation were needed but one has to assume
that there is the need if the OP is using a validation. Just removing
non numeric values will not do the trick if only non numeric values or
'garbage' is entered. You could end up with 'anything' in the field,
for example a phone number containing '123'.

On Jan 25, 11:00 pm, Marnen Laibow-Koser <[email protected]> wrote:
> pepe wrote:
> > Why don't you use 'validates_format_of' instead? You can use a regexp
> > and make sure there are only numbers and dashes. Here is the
> > documentation page:
>
> >http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMeth...
>
> Better yet, don't validate at all.  Instead, just accept any input and
> remove non-numeric characters.  This will enable the user to enter the
> phone number in the format of his choice.
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> [email protected]
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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.

Reply via email to