# Ruby: ArgumentError: wrong number of arguments (given 1, expected 2..3)

**Code:** `ArgumentError: wrong number of arguments (given 1, expected 2)` · **Category:** Ruby / Rails · **Seen on:** Ruby

A method was called with more or fewer arguments than it accepts.

## Meaning

Compare the call with the method signature. Ruby 3 separates positional and keyword arguments: passing a hash where keywords are expected (or the reverse) raises this. Check `initialize` signatures, blocks vs lambdas (lambdas are strict) and `super` calls (`super` vs `super()`).

## Common causes

- Wrong number of positional args
- Ruby 3 keyword vs hash separation (`foo(opts)` vs `foo(**opts)`)
- Lambda/proc strictness
- `super` passing implicit arguments
- Method signature changed after a gem upgrade

## Quick fix

1. Fix the call to match `def m(a, b = 1, *rest, key:)`
2. Use `**opts` when passing a hash as keywords
3. Use `super()` to pass none

## Detailed fix by platform

### Ruby

1. `method(:foo).arity` / `method(:foo).parameters`

## How to diagnose

1. **Given** — How many?
2. **Expected** — Signature?
3. **Ruby 3** — Keyword hash?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ruby/argumenterror-wrong-number-of-arguments)
