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 477
      def find_with_ids(*ids)
        raise UnknownPrimaryKey.new(@klass) if primary_key.nil?

        expects_array = if klass.composite_primary_key?
          ids.first.first.is_a?(Array)
        else
          ids.first.is_a?(Array)
        end

        return [] if expects_array && ids.first.empty?

        ids = ids.first if expects_array

        ids = ids.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
      end
Register or log in to add new notes.