On 9/6/06, joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
<joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Hi,
>
> Say I have this:
>
> class Order < AR
> validates_presence_of :credit_card_number
> validates_presence_of :credit_card_expiry_date
> validate :credit_card_is_good?
> validate_format .... # regex for credit card
> validate_format .... # regex for expiration date
> private
> validate credit_card_is_good?
> # Use the number and expiry date to check against a remote service
> # to see if the card is any good or not
> end
> end
>
> Now, in order to run Order::credit_card_is_good?, I need to be sure
> that the user has entered in a valid credit card number and expiration
> date. But, credit_card_is_good? seems to run before the other
> validations do. Do I want to use after_validate or something for that
> function?
>
> Thanks,
> Joe
Have you tried placing the "validate:credit_card_is_good" line last,
after all the other validations in you class?
- rob
--
http://www.robsanheim.com
http://www.seekingalpha.com
http://www.ajaxian.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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---