Skip to content

Instantly share code, notes, and snippets.

@lasershow
Last active February 17, 2016 06:32
Show Gist options
  • Save lasershow/63341ef89ddc9cc91185 to your computer and use it in GitHub Desktop.
Save lasershow/63341ef89ddc9cc91185 to your computer and use it in GitHub Desktop.
【初心者】railsのvalidatesのpresenceでエラーメッセージが重複するのを防ぐ方法 ref: http://qiita.com/lasershow/items/0229855720aaf2be5fc8
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, format: {with: VALID_EMAIL_REGEX}
・メールアドレスが入力されていません。
・メールアドレスが不正な値です。
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, format: {with: VALID_EMAIL_REGEX}, allow_blank: true
validates :email, presence: true
・メールアドレスが入力されていません。
validates :email,
presence: true,
format: {with: VALID_EMAIL_REGEX, allow_blank: true}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment