LoginSignup
1
1

More than 5 years have passed since last update.

Deviseでpassword_confirmを入力しない方法

Posted at

目的

ユーザー登録時にパスワード確認を入力しないフォームを実現したい。
なにかスマートなやり方があるかも知れますが、とりあえずの対応です。

解決方法

とりあえず、登録前にpassword_confirmフィールドにpasswordを代入する。

obotframeworkb
class Users::RegistrationsController < Devise::RegistrationsController
  before_action :set_password_confirmation! , only: [:create]

  private
  def set_password_confirmation!
    params[:user][:password_confirmation] = params[:user][:password]
    @para = params
    pry
  end
end
routes.rb
#上書きしたいコントローラーを設定
  devise_for :users , :controllers => {
                      :registrations => 'users/registrations' ,
                      :sessions => 'users/sessions'
                    }
1
1
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
1
1