# Restful Form Validations

**URL:** <https://www.ruby-forum.com/t/restful-form-validations/70345>\
**Category:** Rails\
**Created:** [September 28, 2006, 2:43pm UTC](https://www.ruby-forum.com/t/restful-form-validations/70345 "2006-09-28T14:43:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@Jason\_B](https://www.ruby-forum.com/u/Jason_B)\
**Post date:** [September 28, 2006, 2:43pm UTC](https://www.ruby-forum.com/t/restful-form-validations/70345/1 "2006-09-28T14:43:49Z")

</div>

Does the new Restful features of Edge support form validation?

I have “validates\_presence\_of :x” in my model, but rails spills it’s  
beans with and error: “ActiveRecord::RecordInvalid”

What I’d it to do is return the form with the usual fieldWithErrors divs

Has anyone got this working?

thanks 🙂 Jason

---

<div class="post-metadata">

**Author:** ![Jason\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@Jason\_B](https://www.ruby-forum.com/u/Jason_B)\
**Post date:** [February 23, 2007, 5:48pm UTC](https://www.ruby-forum.com/t/restful-form-validations/70345/2 "2007-02-23T17:48:53Z")

</div>

Jason B wrote:

> Does the new Restful features of Edge support form validation?
> 
> I have “validates\_presence\_of :x” in my model, but rails spills it’s  
> beans with and error: “ActiveRecord::RecordInvalid”
> 
> What I’d it to do is return the form with the usual fieldWithErrors divs
> 
> Has anyone got this working?
> 
> thanks 🙂 Jason

the validates\_presence\_of :x will raise an ActiveRecord::RecordInvalid  
exception if :x is not presence. You would have to catch the exception.

For example:

def test  
begin  
s = SomeRecord.new  
s.save  
redirect\_back\_or\_default(:action =\> ‘done’)  
rescue ActiveRecord::RecordInvalid  
render :action =\> ‘test’  
end  
end
