Skip to content

Commit

Permalink
Added error handling to edit profile otherwise if someone filled in j…
Browse files Browse the repository at this point in the history
…ust the password for example.

It would redirect to a blank page and not save anything and the user would be very confused no it displays an error message and allows the user
to fix their mistakes.
  • Loading branch information
Paul committed Mar 15, 2010
1 parent b3810ce commit b2cc14b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 10 additions & 3 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ def update
params[:user][:crypted_password] = current_user.encrypt(params[:user][:password])
flash[:notice] = t(:password_has_been_changed)
end
current_user.update_attributes!(params[:user])
flash[:notice] ||= t(:profile_has_been_updated)
redirect_to edit_user_path(current_user)
respond_to do |format|
if current_user.update_attributes(params[:user])
current_user.update_attributes!(params[:user])
flash[:notice] ||= t(:profile_has_been_updated)
redirect_to edit_user_path(current_user)
else
@themes = Theme.all
format.html { render :action => "edit" }
end
end
end


Expand Down
3 changes: 2 additions & 1 deletion app/views/users/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
= error_messages_for :user
- form_for current_user, :html => { :multipart => true } do |f|
%table.action-box{:cellpadding => "2", :cellspacing => "0", :width => "100%"}
%thead
Expand Down Expand Up @@ -35,7 +36,7 @@
%td.input
= f.text_field "date_display", :size => 10
= f.text_field "time_display", :size => 10
= link_to "read this for more information", "http://noobkit.com/show/ruby/ruby/ruby-core/time/strftime.html"
= link_to "read this for more information", "http://www.wetware.co.nz/blog/2009/07/rails-date-formats-strftime/"
%tr
%td.label{:valign => "top"}
= label_tag "example_time_display", t(:Example_time_display)
Expand Down

0 comments on commit b2cc14b

Please sign in to comment.