On Tue, Jul 21, 2009 at 3:27 AM, miga <[email protected]> wrote:

> > And if you use
> > before_validation_on_create, and before_validation_on_update, it
> > should work.
>
Should work, but is actually a poor programming practice. You should only
use the _on_create or _on_update modifiers when you need to do different
things on those two events. In this case we always need to normalize the
credit card number, so the correct thing to do is to use before_validation
with no 'on' modifier.  Using the modifier as you suggest, leaves two
identical routines inn the code to support and maintain. THis opens the door
to the very real possibility for the introduction of subtle bugs if only one
of the routines were changed in the future (if this was real world code).

>
> >
>

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

Reply via email to