Re: Validation help

François Beausoleil
Wed, 07 Sep 2005 18:17:42 -0000

Adrian Madrid said the following on 2005-09-07 13:38:
> What is the best way to validate a field NOT to be the same as another
> field? I tried doing this unsuccesfully. Any ideas would be apreciated.
>
> validates_each :fieldx do |record, attr|
>     record.errors.add attr, ''must be different from
fieldy'' if attr ==
> fieldy
> end

attr is a Symbol, so you need to do self.send(attr) to get the *value*
of the attribute.

Bye,
François