Anyone ever attempted this ? there are several posts here for people requesting this feature but it never made it as far as I can see, nor any real info on how to get this functionality.
Im sharing my code in hopes we can work this out together.
/app/views/account/edit_password.html.haml:
= simple_form_for(@user, :as => @user, :url => registration_path(@user), :html => { :class => 'form-horizontal', :method => :put }) do |f|
= f.hidden_field :form, :value => "change_email"
.control-group.password.required
%label.password.required.control-label
%abbr
= t('.current_email')
.controls{:style => "margin-top: 10px"}
%h3.grey
= @user.email
.ruler
.clear
= f.input :email, :label => t('.new_email')
= f.input :password, :label => t('.password')
.ruler
.clear
= f.button :submit, t('forms.save'), :class => "span-4"
/app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy, :change_password]
layout "application"
def update
puts "UPDATE ACTION CALLED!!"
puts params
puts params['user'][:change_email]
if resource.update_with_password(params[resource_name])
puts "update regular"
set_flash_message :notice, :updated if is_navigational_format?
sign_in resource_name, resource, :bypass => true
respond_with resource, :location => after_update_path_for(resource)
else
puts "other xxx"
clean_up_passwords(resource)
respond_with_navigational(resource) do
if params['user'][:form] == "change_email"
puts "change the email"
redirect_to account
else
# the default if not change_password and not
# change email
end
end
end
end
Im stuck here how to approach next?
@Jose
Could you share some information on how to approach next?
Would really appreciate any help ! thanks in advanche