devise - Customizing the User Edit Pages

前端 未结 1 1937
独厮守ぢ
独厮守ぢ 2020-12-24 15:32

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:

相关标签:
1条回答
  • 2020-12-24 16:08

    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)

    0 讨论(0)
提交回复
热议问题