On Jul 21, 9:30 pm, Joe Van Overberghe <[email protected]> wrote:
> # Strip everything but numbers
> def before_validation
> self.credit_card = credit_card.gsub(/[^\d]/, "") if
> (attribute_present?("credit_card") && credit_card =~ /\A\d{4}(?:[-|
> ]\d{4}){3}\Z/)
> end
I did not think of putting the user input format together with the
before validation. Thanks very much for the idea; it seems to pass the
tests (a good exercise by the way for testing).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "ruby-on-rails-programming-with-passion" group.
To unsubscribe from this group, send email to
ruby-on-rails-programming-with-passion-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---