Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

devise - Customizing the User Edit Pages

currently with devise & rails 3 there is a one page user edit page: /users/edit

I would like to split that out into sections for a better UI, something like:

/account/settings
/account/password
/account/notices
/account/disable

Also, I'd like to require the user to enter their current password when a user wants to change their password.

With devise, to make this happen, does this require a new controller, or can this all be handled with routes?

Also, currently, the edit page lives here: app/views/devise/registrations

Do you recommend adding these pages there? Or in /app/views/users ?

Thanks

like image 605
AnApprentice Avatar asked Nov 04 '10 22:11

AnApprentice


1 Answers

You have multiple options here. I would go with the first option as it seems to more naturally fit what you are trying to do.

  1. Override devise's registrations controller by inheriting from it, and update the corresponding views and routes. Here is what devise's site says about this:

    Configuring controllers

    If the customization at the views level is not enough, you can customize each controller by following these steps:

    1) Create your custom controller, for example a Admins::SessionsController:

    class Admins::SessionsController < Devise::SessionsController end

    2) Tell the router to use this controller:

    devise_for :admins, :controllers => { :sessions => "admins/sessions" }

    3) And since we changed the controller, it won’t use the "devise/sessions" views, so remember to copy "devise/sessions" to "admin/sessions".

    Remember that Devise uses flash messages to let users know if sign in was successful or failed. Devise expects your application to call "flash[:notice]" and "flash[:alert]" as appropriate.

  2. Use the User controller and add actions there with corresponding views (not my choice)

like image 144
zzawaideh Avatar answered Oct 18 '22 11:10

zzawaideh