From 6506fabd36c39c2e02c49f2dd5b7fd319ee27f10 Mon Sep 17 00:00:00 2001 From: Bryan Larsen Date: Mon, 22 Nov 2010 17:54:12 -0500 Subject: [PATCH] [#857] don't update @current_user if update fails. Credits: Tomoaki Hayasaki and Betelgeuse --- lib/hobo/model_controller.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/hobo/model_controller.rb b/lib/hobo/model_controller.rb index 2ecf1f1a3..7f66beac6 100644 --- a/lib/hobo/model_controller.rb +++ b/lib/hobo/model_controller.rb @@ -590,10 +590,11 @@ def hobo_update(*args, &b) self.this ||= args.first || find_instance changes = options[:attributes] || attribute_parameters or raise RuntimeError, ht(:"hobo.messages.update.no_attribute_error", :default=>["No update specified in params"]) - this.user_update_attributes(current_user, changes) - - # Ensure current_user isn't out of date - @current_user = @this if @this == current_user + + if this.user_update_attributes(current_user, changes) + # Ensure current_user isn't out of date + @current_user = @this if @this == current_user + end in_place_edit_field = changes.keys.first if changes.size == 1 && params[:render] update_response(in_place_edit_field, options, &b)