Forum: Ruby on Rails How do you detect if 'update' save fails?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Justin R. (Guest)
on 2005-12-27 08:34
(Received via mailing list)
So I'm updating multiple model objects in one go with something like
this in my controller:
=>	Photo.update(params[:photo].keys, params[:photo].values)

When the update fails due to validation errors, how do I detect it?
The Rails API says:
"If the save fails under validations, the unsaved object is still
So I can't simply do this:
  =>	if Photo.update(params[:photo].keys, params[:photo].values)

Any suggestions?
Derek C. (Guest)
on 2005-12-27 15:32
(Received via mailing list)
photo=Photo.find params[:id]
unless photo.update_attributes params
   #error handling
This topic is locked and can not be replied to.