Sha256: c093d919479393b48a5d6da259ac1d1e2be7eac2b58b934428657596778fdb1c
Contents?: true
Size: 475 Bytes
Versions: 11
Compression:
Stored size: 475 Bytes
Contents
require 'active_record/connection_adapters/abstract/quoting' module RC module Inclusion include ActiveRecord::ConnectionAdapters::Quoting def add_inclusion_constraint(table, attribute, options = {}) name = "#{table}_#{attribute}" values = options[:in].map {|value| quote(value) }.join(", ") conditions = "#{attribute} IN (#{values})" execute("ALTER TABLE #{table} ADD CONSTRAINT #{name} CHECK (#{conditions})") end end end
Version data entries
11 entries across 11 versions & 1 rubygems