Forum: Ruby on Rails problem with validates_presence_of :on=> :update

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.
Bill W. (Guest)
on 2006-05-14 20:00
(Received via mailing list)
I'm having what's probably a stupid-newbie problem with
validates_presence_of and I'm hoping someone will point me in the right
direction.

Bottom line is that validates_presence_of does not seem to be 'firing'
when I use the :on => :update option.  If I don't include the option,
the validation does fire.

The problem is that I want to save the record before I present it to the
user to update.  When it comes back from the user I want to make sure
they've updated a couple of fields and so that's where I need to do the
validation.

When I leave off the option, the validation is firing on the initial
save.  That's 'bad' because the data is not _supposed_ to be there at
that point.  When I include the :on => :update, it doesn't fire on the
initial save.  That's 'good.'  But if I leave the fields that I'm
validating-on empty when I submit the form, the @actor.update happens
without throwing an error.  The record is definitely getting updated in
the database.  That's very 'bad.'

Anybody have any ideas?
This topic is locked and can not be replied to.