私はデバイスを使用しており、ユーザーが情報を提供せずに情報を変更できるようにしようとしています。チュートリアル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/registrations/edit.erb.html ではなく、/views/devise/registration/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