Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # PUT /users/1
- # PUT /users/1.xml
- def update
- @user = User.find(session[:user_id])
- unless @user.validate_password(params[:user][:current_password])
- @user.attributes = params[:user]
- @user.valid?
- @user.errors.add("current_password")
- render :action => "edit"
- return
- end
- if @user.valid? && !params[:user][:new_password].empty?
- @user.password = params[:user][:new_password]
- end
- respond_to do |format|
- if @user.update_attributes(params[:user])
- flash[:notice] = 'Account details successfully updated.'
- format.html { redirect_to(edit_user_path(@user)) }
- else
- format.html { render :action => "edit" }
- end
- end
- end
Add Comment
Please, Sign In to add comment