Forum: Ruby on Rails Problems with validation []

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ba86dfb8d0feeffb597c31aeb3b0ca3b?d=identicon&s=25 Daniello (Guest)
on 2007-04-09 13:07
(Received via mailing list)
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??
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-04-09 13:37
(Received via mailing list)
it's

validates_presence_of
Ba86dfb8d0feeffb597c31aeb3b0ca3b?d=identicon&s=25 Daniello (Guest)
on 2007-04-09 14:19
(Received via mailing list)
Yes it's validates_presence_of
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-04-09 14:30
(Received via mailing list)
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.
Ba86dfb8d0feeffb597c31aeb3b0ca3b?d=identicon&s=25 Daniello (Guest)
on 2007-04-09 22:37
(Received via mailing list)
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.
54077fb03c95861af85880218cf7aef2?d=identicon&s=25 Gokhan Arli (sylow)
on 2007-04-10 00:56
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
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-04-10 01:05
(Received via mailing list)
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.
This topic is locked and can not be replied to.