Problem with validates_presence_of :on=> :update

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs