On Jan 8, 10:18 pm, Sharad Pratap <[email protected]> wrote:

>
> Class Person < ActibeRecord::Base
>  valid_with_cond :test do
>      if self.addresses > 3
>         errors[:base] << "Can not have more than 3 addresses".
>    end
>  end
> end
>
> But when I check it on console
>
> Person.test
>
> it throw me error test is private method.
>
> Anybody could let me know how to correct it.
>

Your call to attr_accessor will create instance methods called test
and test=, but you tried to call test on the class (and so you end up
falling through to Kernel#test).
Have you seen that validations take :if and :unless options ?

Fred

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