Folks,
I need some help to understand some strange behaviour when using
validates_presence_of
I have a form that updates table row. One field is text and I require it
to be completed.
With no validation in place in the model I can obvioulsy update the row
and either put a text entry in or leave it blank and the update happens
okay.
After adding validate_presence_of :activity to the model ....
I then update with the text item completed and it updates okay.
but if I then update with the text item null I get what appears to be a
totally unrelated error:-
"Called id for nil, which would mistakenly be 4 -- if you really wanted
the id of nil, use object_id" and which points to the code line:-
<form action="../update/<%= @activities.id %>"
method="POST">
Of course what I would expect is to get an "Activity must be
completed"
error.
So when I would expect validate_presence_of to trigger a real validation
error it in fact throws up this other condition.
I suspect the actual error may be unrelated to validate_presence_of but
that the validate routine is merely exposing some other underlying issue
and without the validation in place it all works okay and I dont have
any issues or errors shown!
Confused since the validate_presence_of should be so simple and yet it
throws up this other condition.
Can anyone give me a steer as to what/where I should be investigating
this.
Any help much appreciated!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---