# Problems with validation \[\]

**URL:** <https://www.ruby-forum.com/t/problems-with-validation/91453>\
**Category:** Rails\
**Created:** [April 9, 2007, 1:07pm UTC](https://www.ruby-forum.com/t/problems-with-validation/91453 "2007-04-09T13:07:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/22d042/32.png) [@Daniello](https://www.ruby-forum.com/u/Daniello)\
**Post date:** [April 9, 2007, 1:07pm UTC](https://www.ruby-forum.com/t/problems-with-validation/91453/1 "2007-04-09T13:07:29Z")

</div>

I’ve generated model, controller and then I’ve added validation to my  
model. When I leave my form field empty validation doesn’t appear  
(validate\_presents\_of). How can I fixed it??

---

<div class="post-metadata">

**Author:** ![Daniello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/22d042/32.png) [@Daniello](https://www.ruby-forum.com/u/Daniello)\
**Post date:** [April 9, 2007, 1:37pm UTC](https://www.ruby-forum.com/t/problems-with-validation/91453/2 "2007-04-09T13:37:30Z")

</div>

it’s

validates\_presence\_of

---

<div class="post-metadata">

**Author:** ![Daniello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/22d042/32.png) [@Daniello](https://www.ruby-forum.com/u/Daniello)\
**Post date:** [April 9, 2007, 2:19pm UTC](https://www.ruby-forum.com/t/problems-with-validation/91453/3 "2007-04-09T14:19:36Z")

</div>

Yes it’s validates\_presence\_of

---

<div class="post-metadata">

**Author:** ![Daniello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/22d042/32.png) [@Daniello](https://www.ruby-forum.com/u/Daniello)\
**Post date:** [April 9, 2007, 2:30pm UTC](https://www.ruby-forum.com/t/problems-with-validation/91453/4 "2007-04-09T14:30:37Z")

</div>

what do you mean by ‘when i leave my form field’? i have a feeling  
you are misunderstanding record validation.

record validation != form validation

record validation occurs when you attempt to save your record to the  
database after you have submitted the data to the server.

if you want to validate the form data before you submit, you will have  
to write your own functionality to validate it on the page.

---

<div class="post-metadata">

**Author:** ![Daniello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/22d042/32.png) [@Daniello](https://www.ruby-forum.com/u/Daniello)\
**Post date:** [April 10, 2007, 12:56am UTC](https://www.ruby-forum.com/t/problems-with-validation/91453/5 "2007-04-10T00:56:24Z")

</div>

Daniello wrote:

> I’d like to have the same type of validation like I have when I’m  
> using scaffolding. Simple validation of presence something on my  
> form field.

Hey Daniello,

Why dont you show us the source of model + controller + view that you  
use?

Gokhan  
[www.sylow.net](http://www.sylow.net)

---

<div class="post-metadata">

**Author:** ![Daniello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/22d042/32.png) [@Daniello](https://www.ruby-forum.com/u/Daniello)\
**Post date:** [April 10, 2007, 1:05am UTC](https://www.ruby-forum.com/t/problems-with-validation/91453/6 "2007-04-10T01:05:07Z")

</div>

you create a form based on your model. submit the data, attempt to  
save it. if validations fail, the record won’t be saved and will  
contain errors. you redisplay your form and show your users where  
the errors were made in the form data. if the record saves, then all  
is good.

it’s a bit much to explain in the mailing list. i suggest you review  
the generated scaffolding code and read the Rails book if you can.  
also, google is your friend.

---

<div class="post-metadata">

**Author:** ![Daniello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/22d042/32.png) [@Daniello](https://www.ruby-forum.com/u/Daniello)\
**Post date:** [April 9, 2007, 10:37pm UTC](https://www.ruby-forum.com/t/problems-with-validation/91453/7 "2007-04-09T22:37:47Z")

</div>

I’d like to have the same type of validation like I have when I’m  
using scaffolding. Simple validation of presence something on my  
form field.
