def raise_record_not_found_exception!(ids, result_size, expected_size) #:nodoc:
      if Array(ids).size == 1
        error = "Couldn't find #{@klass.name} with 'id'=#{ids}#{conditions}"
      else
        error = "Couldn't find all #{@klass.name.pluralize} with 'id': "
        error << "(#{ids.join(", ")})#{conditions} (found #{result_size} results, but was looking for #{expected_size})"
      end

      raise RecordNotFound, error
    end
def raise_record_not_found_exception!(ids, result_size, expected_size) #:nodoc:
      if Array(ids).size == 1
        error = "Couldn't find #{@klass.name} with 'id'=#{ids}#{conditions}"
      else
        error = "Couldn't find all #{@klass.name.pluralize} with 'id': "
        error << "(#{ids.join(", ")})#{conditions} (found #{result_size} results, but was looking for #{expected_size})"
      end

      raise RecordNotFound, error
    end
Returns +true+ if a record exists in the table that matches the +id+ or
 conditions given, or +false+ otherwise. The argument can take six forms:

 * Integer - Finds the record with this primary key.
 * String - Finds the record with a primary key corresponding to this
   string (such as <tt>'5'</tt>).
 * Array - Finds the record that matches these +find+-style conditions
   (such as <tt>['name LIKE ?', "%#{query}%"]</tt>).
 * Hash - Finds the record that matches these +find+-style conditions
   (such as <tt>{name: 'David'}</tt>).
 * +false+ - Returns always +false+.
 * No args - Returns +false+ if the table is empty, +true+ otherwise.

 For more information about specifying conditions as a hash or array,
 see the Conditions section in the introduction to <tt>ActiveRecord::Base</tt>.

 Note: You can't pass in a condition as a string (like <tt>name =
 'Jamie'</tt>), since it would be sanitized and then queried against
 the primary key column, like <tt>id = 'name = \'Jamie\''</tt>.

   Person.exists?(5)
   Person.exists?('5')
   Person.exists?(['name LIKE ?', "%#{query}%"])
   Person.exists?(id: [1, 4, 8])
   Person.exists?(name: 'David')
   Person.exists?(false)
   Person.exists?
 def exists?(conditions = :none)
   conditions = conditions.id if Base === conditions
   return false if !conditions

   relation = apply_join_dependency(self, construct_join_dependency)
   return false if ActiveRecord::NullRelation === relation

   relation = relation.except(:select, :order).select(ONE_AS_ONE).limit(1)

   case conditions
     when Array, Hash
       relation = relation.where(conditions)
     else
       relation = relation.where(table[primary_key].eq(conditions)) if conditions != :none
   end

   connection.select_value(relation, "#{name} Exists", relation.bind_values) ? true : false
 end
 This method is called whenever no records are found with either a single
 id or multiple ids and raises a +ActiveRecord::RecordNotFound+ exception.

 The error message is different depending on whether a single id or
 multiple ids are provided. If multiple ids are provided, then the number
 of results obtained should be provided in the +result_size+ argument and
 the expected number of results should be provided in the +expected_size+
 argument.