Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

Rails validations: unique scope

class Project < ApplicationRecord
  belongs_to :account

  has_many :tasks

  validates :name, presence: true, uniqueness: { scope: :account_id }
end
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #Rails #unique #scope
ADD COMMENT
Topic
Name
9+2 =