Rails 2.3.5: How does one add an error when it doesn't make sense to put it in a validation?

Posted by randombits on Stack Overflow See other posts from Stack Overflow or by randombits
Published on 2010-05-11T22:10:18Z Indexed on 2010/05/11 22:14 UTC
Read the original article Hit count: 161

Filed under:
|
|

I recently was trying to add errors.add_to_base code in the middle of some model logic and was wondering why it wasn't showing up in my view that was iterating over all errors. I then ran across this e-mail which explains why: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/e045ec1dead1ff06?pli=1

The question is then, how does one add errors with add_to_base if it doesn't make sense to put them into a validate method? I have some complex logic. The model needs to talk to a has_many relationship which has its own relationships that go through a myriad of conditionals to figure out if a request makes sense. It's nothing that can be tied to a validate method easily.

How does one add errors then accordingly?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby