Skip to content

Commit

Permalink
[#857] don't update @current_user if update fails. Credits: Tomoaki H…
Browse files Browse the repository at this point in the history
…ayasaki and Betelgeuse
  • Loading branch information
bryanlarsen committed Nov 22, 2010
1 parent 2ae2f03 commit 6506fab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/hobo/model_controller.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 6506fab

Please sign in to comment.