Jeff Cole
2006-Jun-22 19:33 UTC
[Rails] error messaging for a form without ActiveRecord model
I have a form that has no ActiveRecord model behind it, it is just composed of random fields like "email_address", "email_body", etc. Even though there is no model, some of these fields are required, and I would like to use the built-in Rails methods for automatically showing errors in the form. Unfortunataely, I can only see how to do this if the form is based on an object whose model extends ActiveRecord. What is the best way to use all the error message functionaity? thanks, Jeff -- Posted via http://www.ruby-forum.com/.
Rohith Ravi
2006-Jun-22 21:59 UTC
[Rails] error messaging for a form without ActiveRecord model
Hey Jeff, I believe the builtin error_messages_for helper simples calls the method errors on the object in question. So I say check out what is returned when u call .errors on a ActiveRecord object with validation errors. Then basically structure your error messages to replicate this behavior. Then you will be able to use error_messages_for on both ActiveRecord objects as well as your custom objects. HTH ~Rohith On 6/22/06, Jeff Cole <jeff@jeffcole.net> wrote:> > I have a form that has no ActiveRecord model behind it, it is just > composed of random fields like "email_address", "email_body", etc. > Even though there is no model, some of these fields are required, and I > would like to use the built-in Rails methods for automatically showing > errors in the form. Unfortunataely, I can only see how to do this if > the form is based on an object whose model extends ActiveRecord. What > is the best way to use all the error message functionaity? > > thanks, > Jeff > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060622/751c2a40/attachment.html