This project is archived and is in readonly mode.
Problem with validates_presence_of
-
judearasu (at gmail)
- Tag changed from validates_presence_of to 2.3.8, validates_presence_of
-
judearasu (at gmail)
- Assigned user set to Yehuda Katz (wycats)
- Tag changed from 2.3.8, validates_presence_of to 2, validates_presence_of
-
Alex Sharp
Can you paste in your model or post a link to a gist?
-
judearasu (at gmail)
in the file :empid attribute is not available in the model.But its throwing Empid can't be blank?.
So whether validates_presence_of will accept non-attributes of the model or not?
-
Alex Sharp
You are validating presence of :empid on line 14:
validates_presence_of :name,:empid,:email,:password,:username
I'm not sure I understand the incorrect behavior here.
-
judearasu (at gmail)
Actually :empid attribute is not available in model.
My user model is having :name,:email
so as per the validates_presence_of it should take only the attributes :name and :email.
But it is accepting the wrong attributes also.
Whether validates_presence_of will the take model attributes or any word starts with :
-
judearasu (at gmail)
- No changes were found…
-
Alex Sharp
I don't think it's the responsibility of Rails validations to make sure that the validations you've defined map to actual database fields. Your validations are model (behavior) logic, not persistence logic. Moreover, you may indeed want to have validations on model attributes that don't exist in the database. In my opinion, this is the correct behavior, not a bug.
-
Andrea Campi
- Tag changed from 2, validates_presence_of to 2-3-stable, validates_presence_of
-
Aditya Sanghi
- State changed from new to invalid
- Importance changed from to Low
I thought validations on virtual attributes was a feature. Invalidating the ticket. If you feel otherwise please chime in and continue discussion.