Skip to content

Commit

Permalink
Show flash message in the correct locale after updating the Typus.use…
Browse files Browse the repository at this point in the history
…r_class.
  • Loading branch information
Francesc Esplugas committed Feb 13, 2010
1 parent 6fd42e3 commit ab800cc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/controllers/admin/master_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,19 @@ def update
@item.update_attributes Typus.user_fk => @current_user.id
end

flash[:success] = _("{{model}} successfully updated.", :model => @resource[:human_name])
path = if @resource[:class].typus_options_for(:index_after_save)
params[:back_to] ? "#{params[:back_to]}##{@resource[:self]}" : { :action => 'index' }
else
{ :action => @resource[:class].typus_options_for(:default_action_on_item), :id => @item.id, :back_to => params[:back_to] }
end

# Reload @current_user when updating to see flash message in the
# correct locale.
if @resource[:class].eql?(Typus.user_class)
I18n.locale = @current_user.reload.preferences[:locale]
end

flash[:success] = _("{{model}} successfully updated.", :model => @resource[:human_name])
redirect_to path

else
Expand Down

0 comments on commit ab800cc

Please sign in to comment.