ruby-on-rails – devise – 自定义用户编辑页面

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – devise – 自定义用户编辑页面前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
目前与设计& rails 3有一页用户编辑页面:/ users / edit

我想将它分成几个部分,以获得更好的UI,类似于

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

此外,当用户想要更改密码时,我想要求用户输入他们当前的密码.

有了设计,为了实现这一点,这需要一个新的控制器,还是可以用路由来处理?

另外,编辑页面目前位于这里:app / views / devise / registration

你建议在这里添加这些页面吗?或在/ app / views / users?

谢谢

解决方法

这里有多个选项.我会选择第一个选项,因为它似乎更符合你想要做的事情.

>通过继承设备来重写设备的注册控制器,并更新相应的视图和路由.这是什么设计的site这样说:

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.

>使用用户控制器并在其中添加相应的视图(不是我的选择)

原文链接:https://www.f2er.com/ruby/272829.html

猜你在找的Ruby相关文章