Flowdock
method

find_with_ids

Importance_0
find_with_ids(*ids) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 420
      def find_with_ids(*ids)
        raise UnknownPrimaryKey.new(@klass) if primary_key.nil?

        expects_array = ids.first.kind_of?(Array)
        return [] if expects_array && ids.first.empty?

        ids = ids.flatten.compact.uniq

        model_name = @klass.name

        case ids.size
        when 0
          error_message = "Couldn't find #{model_name} without an ID"
          raise RecordNotFound.new(error_message, model_name, primary_key)
        when 1
          result = find_one(ids.first)
          expects_array ? [ result ] : result
        else
          find_some(ids)
        end
      rescue ::RangeError
        error_message = "Couldn't find #{model_name} with an out of range ID"
        raise RecordNotFound.new(error_message, model_name, primary_key, ids)
      end
Register or log in to add new notes.