Sha256: 0dd94bec5e35a64975cf55928fe73d57819ab01ff5b9e333d008df10fdd82d98
Contents?: true
Size: 1.53 KB
Versions: 12
Compression:
Stored size: 1.53 KB
Contents
module ActiveRecord module Core def initialize_dup(other) # :nodoc: @attributes = @attributes.dup # CPK # @attributes.reset(self.class.primary_key) Array(self.class.primary_key).each {|key| @attributes.reset(key)} run_callbacks(:initialize) unless _initialize_callbacks.empty? @aggregation_cache = {} @association_cache = {} @new_record = true @destroyed = false super end module ClassMethods def find(*ids) # :nodoc: # We don't have cache keys for this stuff yet return super unless ids.length == 1 return super if block_given? || primary_key.nil? || scope_attributes? || columns_hash.include?(inheritance_column) # CPK return super if self.composite? id = ids.first return super if StatementCache.unsupported_value?(id) key = primary_key statement = cached_find_by_statement(key) { |params| where(key => params.bind).limit(1) } record = statement.execute([id], connection).first unless record raise RecordNotFound.new("Couldn't find #{name} with '#{primary_key}'=#{id}", name, primary_key, id) end record rescue ::RangeError raise RecordNotFound.new("Couldn't find #{name} with an out of range value for '#{primary_key}'", name, primary_key) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems