On 8 Sep 2008, at 15:05, [EMAIL PROTECTED] wrote:

>
> I guess I'm slow.  How would that look with the code above? -
>
just add it to the if you've got.

Fred
> On Sep 8, 1:23 am, Frederick Cheung <[EMAIL PROTECTED]>
> wrote:
>> 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- Hide quoted text -
>>
>> - Show quoted text -- Hide quoted text -
>>
>> - Show quoted text -
> >


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

Reply via email to