deviseを用いsign_up,sign_in機能を実装しています。
よくある、パスワードの文字数指定について、どこに何を追記すべきかメモしておきます。
環境
rails (5.2.4.2)
userモデルの:validatableに続けて、password_length: (指定文字数)..128と
記載すればOKです。
※128の意味は勉強中
7文字以上としたい場合は以下のようになります。
user.rb
class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable, password_length: 7..128
validates :nickname, :password, :email, :last_name, :first_name, :ruby_last_name, :ruby_first_name, :birthdate, presence: true
has_many :products
has_one :ship_address
end
他にもいろいろと方法はあるようですが、比較的わかりやすいもののメモでした。
参考にさせていただいた記事
https://qiita.com/hirokihello/items/862284c60429be5e01cd
誤認識等あればご指摘いただければ幸いです🙇♂️