On Sep 7, 11:42 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have this validation rule to check if the user-entered date of birth
> is at least 18 years of age ...
>
> validates_each :date_of_birth do |record, attr, value|
> record.errors.add attr, "You must be at least 18 years old to
> use this site." if value > Date.new((Date.today.year - 18),
> (Date.today.month),(Date.today.day))
> end
>
> Now I want to refine this so it validation only occurs if this
> condition above is true and the user_type_id virtual attribute is
> equal to one. How do I add this additional piece of logic into my
> validation rule?
Just add record.user_type_id == 1 to that condition.
Fred
>
> Thanks, - Dave
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---