Skip to content

Commit

Permalink
don't update @current_user if update fails. Credits: Tomoaki Hayasaki…
Browse files Browse the repository at this point in the history
… and Betelgeuse [#857 state:resolved]
  • Loading branch information
ddnexus committed Nov 27, 2010
1 parent 08e2b92 commit 072cda6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hobo/lib/hobo/controller/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,11 @@ def hobo_update(*args, &b)

self.this ||= args.first || find_instance
changes = options[:attributes] || attribute_parameters or raise RuntimeError, t("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 072cda6

Please sign in to comment.