This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# NOT NULL 制約の定義されている列に対し、自動的に presence バリデーションを付与します | |
# | |
module AutoPresenceValidation | |
extend ActiveSupport::Concern | |
included do | |
ignore_types = %i[boolean] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/hoge.rb | |
class Hoge < ApplicationRecord | |
validates :foo, presence: true | |
validates :bar, presence: true | |
validates :foo, uniqueness: { scope: [:bar] } | |
end |
OlderNewer