Raise exception if save or update failed.

This commit is contained in:
Martin Edenhofer 2013-05-29 18:09:02 +02:00
parent bce0324139
commit 5ee16d758b

View file

@ -213,9 +213,11 @@ class ApplicationController < ActionController::Base
generic_object = object.new( object.param_cleanup(params) ) generic_object = object.new( object.param_cleanup(params) )
# save object # save object
generic_object.save generic_object.save!
model_create_render_item(generic_object) model_create_render_item(generic_object)
rescue Exception => e rescue Exception => e
puts e.message.inspect
logger.error e.message logger.error e.message
render :json => { :error => e.message }, :status => :unprocessable_entity render :json => { :error => e.message }, :status => :unprocessable_entity
end end
@ -231,7 +233,7 @@ class ApplicationController < ActionController::Base
generic_object = object.find( params[:id] ) generic_object = object.find( params[:id] )
# save object # save object
generic_object.update_attributes( object.param_cleanup(params) ) generic_object.update_attributes!( object.param_cleanup(params) )
model_update_render_item(generic_object) model_update_render_item(generic_object)
rescue Exception => e rescue Exception => e
logger.error e.message logger.error e.message