5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

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>
   :
   :
   :
5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?