我正在使用设计,我试图允许用户在不提供信息的情况下修改他们的信息。我已按照教程https://github.com/plataformatec/devise/wiki/How-To%3a-Allow-users-to-edit-their-account-without-providing-a-password。
我有这个链接允许用户更改他们自己的设置
<%= link_to "Account Settings", edit_user_registration_path(current_user) %>
我做了什么
rails g controller Registration
在注册控制器中,用这个替换内容
class RegistrationsController < Devise::RegistrationsController
def update
@user = User.find(current_user.id)
email_changed = @user.email != params[:user][:email]
password_changed = !params[:user][:password].empty?
successfully_updated = if email_changed or password_changed
@user.update_with_password(params[:user])
else
@user.update_without_password(params[:user])
end
if successfully_updated
set_flash_message :notice, :updated
# Sign in the user bypassing validation in case his password changed
sign_in @user, :bypass => true
redirect_to after_update_path_for(@user)
else
render "edit"
end
end
end
在 route.rb 文件中我这样做了
devise_for :users, :controllers => { :registrations => "registrations" }
但它仍然把我带到文件夹/views/devise/registration/edit.erb.html,而不是把我带到/views/registrations/edit.erb.html。我还重新启动了服务器和我的电脑,但不知道还能做什么
更新:注意(客户=用户)
Started GET "/customers/edit.2" for 127.0.0.1 at 2012-12-09 20:06:03 -0500
Processing by Devise::RegistrationsController#edit as
[1m[35mCustomer Load (0.3ms)[0m SELECT `customers`.* FROM `customers` WHERE `customers`.`id` = 2 LIMIT 1
[1m[36mPage Load (0.2ms)[0m [1mSELECT `pages`.* FROM `pages` [0m
[1m[35mTag Load (0.2ms)[0m SELECT `tags`.* FROM `tags`
Rendered devise/registrations/edit.html.erb within layouts/application (0.1ms)
Rendered layouts/_shim.html.erb (0.0ms)
Rendered layouts/_iewrap.html.erb (0.0ms)
Rendered layouts/_header.html.erb (1.1ms)
Rendered layouts/_search_tags.html.erb (0.0ms)
Rendered layouts/_navigation.html.erb (0.8ms)
Rendered layouts/_thirdcol.html.erb (0.0ms)
Rendered pages/_link.html.erb (0.0ms)
Rendered layouts/_footer.html.erb (0.4ms)
Completed 200 OK in 41ms (Views: 36.4ms | ActiveRecord: 0.7ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2012-12-09 20:06:04 -0500
Served asset /application.css - 304 Not Modified (5ms)
Started GET "/assets/activity_managers.css?body=1" for 127.0.0.1 at 2012-12-09 20:06:04 -0500
Served asset /activity_managers.css - 304 Not Modified (0ms)
这是我要走的路
http://localhost:3000/customers/edit.2