On 22 November 2012 10:51, ariv arasan <[email protected]> wrote:
> yes, custom validation helps me.
>
> i modified your code a little for my need,
>
> validate :validates_father_is_a_male
>
> private
>
> def validates_father_is_a_male
>   errors.add(:father_id, 'is not a male') if father && father.sex ==
> 'female'
> end

Don't forget to allow for some of the less conventional situations
that can occur in modern life where male and female conditions are not
immutable and parents may not necessarily be of different sexes.  It
is possible for someone classed as female to also be a father.  It may
be better to allow the user to worry about these things rather than
force validations on them.

Colin

-- 
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 https://groups.google.com/groups/opt_out.


Reply via email to