views:

16

answers:

1

I'm trying to create a form validation.

I added @user.errors.add_to_base "TEST" to my controller, and if I call @user.valid?, it returns false (yes, this is correct). But the error "TEST" isn't displayed (errors from the model, like from validates_presence_of, are).

Why does it 'delete' my error? How can I avoid it?

+1  A: 

This behavior is correct. valid? method really cleans the errors array. The problem is in the way you are using it. Is there any reason why do you generate errors in the controller? This should be the business of model validation and it's one of the main responsibilities of a model. Maybe if you provided us with some more code, so we could figure out what went wrong?

Milan Novota