On Jul 21, 11:51 am, Joe Van Overberghe <[email protected]> wrote:
> 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).
Oh, no I have only one routine I call on both before_validations
(create and update).
I've tried with just before_validation, but in this case, it does not
work correctly on update, at least I did not find a way to make it
work in all cases.
And as there are not used at the same time, it works.
Anyway, now that I'm on testing which I don't know well, I'm trying to
test the validations to see if I can find to make it work the way you
said it should be done.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---