views:

91

answers:

2

I have a simple contact form with Subject and Message that I want to validate to prevent blank e-mails.

ActionMailer doesn't support validation. Where should I put it (i.e. in a separated model or directly in controller)?

UPDATE: what is the best way to implement validation in a non ActiveRecord model?

+1  A: 

Does this help any? http://forums.site5.com/showthread.php?t=18522

thebrokencube
I don't think it is a good practice to exdend ActiveRecord::Base in this case.
collimarco
Hmm... Well if this is the only place you'll be doing that and you don't want to use a separate model, it'll probably be fine if you just do it in the controller. It's probably not best practice, but since it's such a small thing anyways, it doesn't really matter where you stick the validation code. Alternatively, you could look into client-side validation.
thebrokencube
A: 

Maybe this helps you: http://activeform.rubyforge.org/

Lichtamberg