# Validating form that is not bounded to Model

**URL:** <https://www.ruby-forum.com/t/validating-form-that-is-not-bounded-to-model/189533>\
**Category:** Rails\
**Created:** [June 2, 2010, 4:11pm UTC](https://www.ruby-forum.com/t/validating-form-that-is-not-bounded-to-model/189533 "2010-06-02T16:11:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![builtbysimple](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/aca169/32.png) [@builtbysimple](https://www.ruby-forum.com/u/builtbysimple)\
**Post date:** [June 2, 2010, 4:11pm UTC](https://www.ruby-forum.com/t/validating-form-that-is-not-bounded-to-model/189533/1 "2010-06-02T16:11:53Z")

</div>

Hi all,

I would like to validate a form, but this form is not bounded to a  
Model? What would be the best approach to do this in Rails? I tried to  
look in the Rails guide with no luck. Can anybody share their  
experience please?

Thank you very much in advance.

Kind regards,  
Joshua

–  
[http://twitter.com/scrum8](http://twitter.com/scrum8)

---

<div class="post-metadata">

**Author:** ![builtbysimple](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/aca169/32.png) [@builtbysimple](https://www.ruby-forum.com/u/builtbysimple)\
**Post date:** [June 3, 2010, 9:51am UTC](https://www.ruby-forum.com/t/validating-form-that-is-not-bounded-to-model/189533/2 "2010-06-03T09:51:57Z")

</div>

You could do it in the controller action the form posts to. Or, if  
you want to keep your controller skinny you could possibly create a  
model not associated with a database table with validation methods and  
call object.valid? from the controller but never call object.save You  
could alternately create a new class that would validate the form data  
but that may or may not take more work on your part. There are a  
number of approaches that might work.

Personally, if the validations would be quick and simple (like  
checking the length of a field) then I would do it from the  
controller, if I knew I would have to use more than, say, 10 lines, or  
the validations are non-trivial, I would use a model/class.

If you need a more specific guidance you should possibly paste the  
form and provide additional details as to what you’re trying to  
accomplish.
