Help us understand the problem. What is going on with this article?

deviseを用いたアカウント編集のupdateを「現在のパスワード」を確認せずにする方法。

More than 1 year has passed since last update.

deviseを用いたアカウント編集では、編集したあとupdateする際にデフォルトでは「現在のパスワード」を入力しなくてはいけないことになっている。

そのupdateを「現在のパスワード」を確認せずにする方法をまとめる。ここを参照

1,registrations_controller.rbを新規作成。その中に以下を記載。

registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController

  protected

  def update_resource(resource, params)
    resource.update_without_password(params)
  end
end

2,routes.rbに以下を追加

routes.rb
devise_for :users, controllers: { registrations: 'registrations' } 

3,devise/registrations/edit.html.erbから以下のコードを削除

devise/registrations/edit.html.erb
   :
   :
<div class="field">
    <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
    <%= f.password_field :current_password, autocomplete: "off" %>
</div>
   :
   :
   :
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした