mercredi 7 octobre 2015

devise account seperate: change password and edit account information

I am trying to create 2 separate pages for changing account info using devise. 1 page for users to change their account information (name, email etc) and 1 page to change their password by entering a new password twice and their current password. currently I can only get the edit account page to work. I've found pages like:

http://ift.tt/NjwFZQ http://ift.tt/1fpIOKf

But I haven't been able to combine them since they both refer to the same controller and view. (call me a noob if I misunderstood). There is a very similar topic already made, but I am unable to filter a working solution for myself:

How to separate change password from devise form

This is what I got for a working user edit (it's in haml):

registrations/edit.html.haml

%h2 Edit #{resource_name.to_s.humanize}
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
  = f.error_notification
  .form-inputs
    = f.input :name, required: true, label: false, placeholder: t("account.name")
    = f.input :email, required: true, label: false, placeholder: t("account.email")
    = f.button :submit, t("account.update")

registrations controller

def update_resource(resource, params)
  resource.update_without_password(params)
end

Since the solution to password change is by editing the same controller and view in a different way I am not sure how to combine the two.

Aucun commentaire:

Enregistrer un commentaire