I recently upgraded to Rails 6 with Ruby 3. I have this in a controller
my_object = MyObject.new(my_object_params, @header)
The object “initialize” method is defined like so
def initialize(params, header)
super(params)
user&.header = header
end
But now when attempting to initialize the object, I get the error
ArgumentError:
wrong number of arguments (given 2, expected 0..1)
What’s the proper way in Ruby 3 to pass multiple arguments to an object during initialization?
You need to do this way: