How to raise validation errors from Rails Controller?
问题 I am dealing with some weird stuff. I am looking at request.env['recaptcha.valid'] a special key I added to the request variable available only to Rails controllers. Depending on the state of the above variable, how can I raise a rails validation error from the Rails controller rather than dealing with this logic in the Model? 回答1: Look into before_filter , which can choose to render or redirect, or simply set some internal state ( @captcha_failed = true ) before your action is invoked. You