Bill Walton
2006-May-14 15:59 UTC
[Rails] 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? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060514/62ee1641/attachment.html