From b3517969862b03a0ac47aca756ef0b5251a93657 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 29 May 2013 18:09:02 +0200 Subject: [PATCH] Raise exception if save or update failed. --- app/controllers/application_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 791616002..b4d5fe246 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -213,9 +213,11 @@ class ApplicationController < ActionController::Base generic_object = object.new( object.param_cleanup(params) ) # save object - generic_object.save + generic_object.save! + model_create_render_item(generic_object) rescue Exception => e + puts e.message.inspect logger.error e.message render :json => { :error => e.message }, :status => :unprocessable_entity end @@ -231,7 +233,7 @@ class ApplicationController < ActionController::Base generic_object = object.find( params[:id] ) # save object - generic_object.update_attributes( object.param_cleanup(params) ) + generic_object.update_attributes!( object.param_cleanup(params) ) model_update_render_item(generic_object) rescue Exception => e logger.error e.message