Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

628
Vistas
Rails 2.4 => 3.0: ActiveRecord: `add_modifier`: wrong number of arguments (given 3, expected 2) (ArgumentError)

When I update my Ruby version from 2.4.3 to 3.0.2, (bundle update), and try to run the Rails console, I get this error message. How can I resolve this?

C:\Users\Chloe\workspace\catalyst_research>rails console
C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/type/adapter_specific_registry.rb:7:in `add_modifier': wrong number of arguments (given 3, expected 2) (ArgumentError)
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/type.rb:22:in `add_modifier'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:827:in `<class:PostgreSQLAdapter>'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:69:in `<module:ConnectionAdapters>'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `<module:ActiveRecord>'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activerecord-5.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:19:in `<main>'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from C:/ruby30/lib/ruby/gems/3.0.0/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `block in require'
...
C:/Users/Chloe/workspace/catalyst_research/config/environment.rb:5:in
...

Gemfile:

ruby '~>2.4.1'#'~>3.0.2'
gem 'rails', '~> 5.0.2'
...

environment.rb:5:

Rails.application.initialize!

adapter_specific_registry.rb:7:

  6     class AdapterSpecificRegistry < ActiveModel::Type::Registry
  7       def add_modifier(options, klass, **args)
  8         registrations << DecorationRegistration.new(options, klass, **args)
  9       end
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Rails 5.0.X is not compatible with Ruby 3.0 - period. And that won't change as its no longer maintained.

Rails 6.0.2 is the earliest Rails version which is compatible with Ruby 3.0.

Ruby 3.0 has some significant changes. Especially the separation of keyword arguments from positional arguments which is the most likely cause of the error you're getting.

In previous versions of Ruby you could call the method as:

add_modifier({ foo: 1 }, klass, { bar : 1 })

And Ruby would automatically convert the last positional argument to keyword arguments. This was deprecated and will issue a warning in Ruby 2.7 and was completely removed in Ruby 3.0. You're getting (given 3, expected 2) as the last argument is treated as a positional argument.

If you want to pass a hash as keyword arguments in Ruby 3 you need to use a double splat to convert it:

add_modifier({ foo: 1 }, klass, **{ bar : 1 })

TLDR

You need to find a different upgrade path where you upgrade your Ruby version incrementally as you upgrade the project to newer versions of Rails.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda