Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Devise separate Edit registration form into two forms

I want to separate Devise's edit registration form into two separate pages, something like site/edit and site/settings. Settings page would be for fields like password, email, etc. while edit would just be for user information. How would I go about accomplishing this I haven't really found much documentation on this.

like image 828
iamdhunt Avatar asked Jan 30 '26 01:01

iamdhunt


1 Answers

I've figured this one out on my own and I didn't have to create a separate model, trying to keep everything simple for future integration. I'll post my answer for anyone else who may run into this problem. Surprised there wasn't clearer documentation on this.

Create a separate RegistrationsController that inherits from Devise's generated controller:

class RegistrationsController < Devise::RegistrationsController
    def settings
        @member = current_member
        if @member 
            render :settings
        else
            render file: 'public/404', status: 404, formats: [:html]
         end 
    end
 end

Create the corresponding view in your Devise registrations folder (I just copied the fields I needed from the existing edit form) and then call to the method in your routes:

devise_scope :member do 
     root :to => 'devise/registrations#new'
     match '/settings' => 'registrations#settings', as: :settings
end 
like image 71
iamdhunt Avatar answered Feb 01 '26 17:02

iamdhunt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!