Files
growstuff/app/controllers/registrations_controller.rb
Skud 9b458070e0 Settings form now works (and is prettified)
Had to add some Devise crud based on advice on their wiki, otherwise
you couldn't change your settings without changing your password.

Also had to make a hidden field for tos_agreement. I don't really love
it but nobody seems to be able to recommend a better way.
2013-02-06 15:54:43 +11:00

25 lines
959 B
Ruby

# we need this subclass so that Devise doesn't force people to change their
# password every time they want to edit their settings. Code copied from
# https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-account-without-providing-a-password
class RegistrationsController < Devise::RegistrationsController
def update
# required for settings form to submit when password is left blank
if params[:member][:password].blank?
params[:member].delete("password")
params[:member].delete("password_confirmation")
params[:member].delete("current_password")
end
@member = Member.find(current_member.id)
if @member.update_attributes(params[:member])
set_flash_message :notice, :updated
# Sign in the member bypassing validation in case his password changed
sign_in @member, :bypass => true
redirect_to after_update_path_for(@member)
else
render "edit"
end
end
end