Sha256: 652321a825dbeb096d42c3f9aab7a940b37793e66b69a1f27fc20eb68f1ad805
Contents?: true
Size: 1.23 KB
Versions: 18
Compression:
Stored size: 1.23 KB
Contents
module ActiveRecord module AttributeMethods module PrimaryKey module ClassMethods def suppress_composite_primary_key(pk) pk # return pk unless pk.is_a?(Array) # # warn <<~WARNING # WARNING: Active Record does not support composite primary key. # # #{table_name} has composite primary key. Composite primary key is ignored. # WARNING end end # Returns the primary key previous value. def id_was # CPK # attribute_was(self.class.primary_key) if self.composite? self.class.primary_keys.map do |key_attr| attribute_changed?(key_attr) ? changed_attributes[key_attr] : self.ids_hash[key_attr] end else attribute_was(self.class.primary_key) end end def id_in_database # CPK # attribute_in_database(self.class.primary_key) if self.composite? self.class.primary_keys.map do |key_attr| attribute_in_database(key_attr) end else attribute_in_database(self.class.primary_key) end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems