0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

バリデーション 【備忘録】

Posted at

バリデーションの基本的な意味と初期設定について

class User < ApplicationRecord
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable
         validates :nickname,           presence: true #ニックネームの欄は要入力の意味
         validates :email,              presence: true, unique:true #以下説明
         validates :encrypted_password, presence: true, #以下説明
         end

validatable モジュールがデフォルトでメールアドレスの形式と存在をチェックするから記述不要。
validatable モジュールがデフォルトでパスワードの長さ(6文字以上)や存在をチェックする。presence: true や length: { minimum: 6 } のバリデーションはDeviseの validatable モジュールに含まれているためこれも記述不要。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?