Why does calling .valid? clear out existing errors?

2 views
Skip to first unread message

Altonymous

unread,
Oct 31, 2012, 6:11:12 PM10/31/12
to plataforma...@googlegroups.com
I'm not sure why this is happening, but it seems that when I call current_user.valid? it remove any errors that are currently on the user object.

ie.

current_user.errors.add(:custom_field, "invalid")
current_user.errors.count # == 1
current_user.valid?
current_user.errors.count # == 0

I don't want to add a validation to the user object because this validation only occurs in some contexts and the model doesn't have the context it needs.

How can I go about this?
Reply all
Reply to author
Forward
0 new messages