Problems with validation []

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??

it’s

validates_presence_of

Yes it’s validates_presence_of

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.

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

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.

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.