Ruby 3.1.2: Still getting ArgumentError: wrong number of arguments (given 2, expected 1)
svpersteve opened this issue · 10 comments
What I tried to do
We're upgrading to Ruby 3.1.2 (from 2.7.3) and we're still getting argument errors for several calls to I18n.translate
in our controllers. They all look similar to this:
t("update.success", model: Diagnosis.model_name.human)
We've tried renaming 'model' to something arbitrary. Also it only seems to happen in controllers, in the views we're using translations in the same way and it works fine (slim template):
= link_to t("action.edit_model",
model: ClinicalTeam.model_name.human),
edit_team_clinical_team_path(@clinical_team),
class: "secondary-button small-button"
What I expected to happen
It to work as it did in Ruby 2.7.
We thought this was fixed in 1.8.6 (and 1.8.2?). Upgrading to the latest version causes other breaking changes we'd like to deal with later. We can see nobody else seems to have this issue though so it's probably something we've done/not done...
What actually happened
1) Diagnosis update endpoint when authenticated presents a form that can be used to update an existing Diagnosis
Failure/Error: redirect_to team_diagnoses_path, notice: t("update.success", model: Diagnosis.model_name.human)
ArgumentError:
wrong number of arguments (given 2, expected 1)
Versions of i18n, rails, and anything else you think is necessary
I18n 1.8.6, Rails 7.0.3.1, Ruby 3.1.2
Note we've forced Psych to stay on v3 because of other breaking changes, wondering if it's that. I'm going to try upgrading to 4.
[actionpack (7.0.3.1) lib/abstract_controller/translation.rb:17:in `translate'](http://localhost:3000/team/adir_report_templates#)
[rectify (0.8.0) lib/rectify/command.rb:22:in `method_missing'](http://localhost:3000/team/adir_report_templates#)
[app/controllers/team/adir_report_templates_controller.rb:17:in `block (2 levels) in update'](http://localhost:3000/team/adir_report_templates#)
[wisper (1.6.1) lib/wisper/registration/block.rb:5:in `broadcast'](http://localhost:3000/team/adir_report_templates#)
[wisper (1.6.1) lib/wisper/publisher.rb:65:in `block in broadcast'](http://localhost:3000/team/adir_report_templates#)
[/Users/stevebrewer/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/set.rb:511:in `each_key'](http://localhost:3000/team/adir_report_templates#)
[/Users/stevebrewer/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/set.rb:511:in `each'](http://localhost:3000/team/adir_report_templates#)
[wisper (1.6.1) lib/wisper/publisher.rb:64:in `broadcast'](http://localhost:3000/team/adir_report_templates#)
[app/core/adirs/update_question_options.rb:14:in `call'](http://localhost:3000/team/adir_report_templates#)
[rectify (0.8.0) lib/rectify/command.rb:8:in `call'](http://localhost:3000/team/adir_report_templates#)
[app/controllers/team/adir_report_templates_controller.rb:15:in `update'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/abstract_controller/base.rb:215:in `process_action'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_controller/metal/rendering.rb:53:in `process_action'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/abstract_controller/callbacks.rb:234:in `block in process_action'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/callbacks.rb:118:in `block in run_callbacks'](http://localhost:3000/team/adir_report_templates#)
[app/controllers/application_controller.rb:22:in `set_sentry_context'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'](http://localhost:3000/team/adir_report_templates#)
[audited (5.0.2) lib/audited/sweeper.rb:16:in `around'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'](http://localhost:3000/team/adir_report_templates#)
[audited (5.0.2) lib/audited/sweeper.rb:16:in `around'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/callbacks.rb:138:in `run_callbacks'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/abstract_controller/callbacks.rb:233:in `process_action'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_controller/metal/rescue.rb:22:in `process_action'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/notifications.rb:206:in `block in instrument'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/notifications.rb:206:in `instrument'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_controller/metal/instrumentation.rb:66:in `process_action'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'](http://localhost:3000/team/adir_report_templates#)
[activerecord (7.0.3.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/abstract_controller/base.rb:151:in `process'](http://localhost:3000/team/adir_report_templates#)
[actionview (7.0.3.1) lib/action_view/rendering.rb:39:in `process'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_controller/metal.rb:188:in `dispatch'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_controller/metal.rb:251:in `dispatch'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/journey/router.rb:32:in `each'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/journey/router.rb:32:in `serve'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/routing/route_set.rb:852:in `call'](http://localhost:3000/team/adir_report_templates#)
[bullet (7.0.1) lib/bullet/rack.rb:15:in `call'](http://localhost:3000/team/adir_report_templates#)
[flipper (0.24.0) lib/flipper/middleware/memoizer.rb:77:in `memoized_call'](http://localhost:3000/team/adir_report_templates#)
[flipper (0.24.0) lib/flipper/middleware/memoizer.rb:42:in `call'](http://localhost:3000/team/adir_report_templates#)
[omniauth (2.0.4) lib/omniauth/strategy.rb:202:in `call!'](http://localhost:3000/team/adir_report_templates#)
[omniauth (2.0.4) lib/omniauth/strategy.rb:169:in `call'](http://localhost:3000/team/adir_report_templates#)
[omniauth (2.0.4) lib/omniauth/builder.rb:45:in `call'](http://localhost:3000/team/adir_report_templates#)
[rack (2.2.4) lib/rack/tempfile_reaper.rb:15:in `call'](http://localhost:3000/team/adir_report_templates#)
[rack (2.2.4) lib/rack/etag.rb:27:in `call'](http://localhost:3000/team/adir_report_templates#)
[rack (2.2.4) lib/rack/conditional_get.rb:40:in `call'](http://localhost:3000/team/adir_report_templates#)
[rack (2.2.4) lib/rack/head.rb:12:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/http/permissions_policy.rb:38:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/http/content_security_policy.rb:36:in `call'](http://localhost:3000/team/adir_report_templates#)
[message_bus (3.3.8) lib/message_bus/rack/middleware.rb:61:in `call'](http://localhost:3000/team/adir_report_templates#)
[rack (2.2.4) lib/rack/session/abstract/id.rb:266:in `context'](http://localhost:3000/team/adir_report_templates#)
[rack (2.2.4) lib/rack/session/abstract/id.rb:260:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/cookies.rb:697:in `call'](http://localhost:3000/team/adir_report_templates#)
[activerecord (7.0.3.1) lib/active_record/migration.rb:603:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/callbacks.rb:99:in `run_callbacks'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/executor.rb:14:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'](http://localhost:3000/team/adir_report_templates#)
[sentry-rails (5.4.1) lib/sentry/rails/rescued_exception_interceptor.rb:12:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'](http://localhost:3000/team/adir_report_templates#)
[web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app'](http://localhost:3000/team/adir_report_templates#)
[web-console (4.2.0) lib/web_console/middleware.rb:28:in `block in call'](http://localhost:3000/team/adir_report_templates#)
[web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch'](http://localhost:3000/team/adir_report_templates#)
[web-console (4.2.0) lib/web_console/middleware.rb:17:in `call'](http://localhost:3000/team/adir_report_templates#)
[sentry-ruby (5.4.1) lib/sentry/rack/capture_exceptions.rb:28:in `block (2 levels) in call'](http://localhost:3000/team/adir_report_templates#)
[sentry-ruby (5.4.1) lib/sentry/hub.rb:199:in `with_session_tracking'](http://localhost:3000/team/adir_report_templates#)
[sentry-ruby (5.4.1) lib/sentry-ruby.rb:372:in `with_session_tracking'](http://localhost:3000/team/adir_report_templates#)
[sentry-ruby (5.4.1) lib/sentry/rack/capture_exceptions.rb:19:in `block in call'](http://localhost:3000/team/adir_report_templates#)
[sentry-ruby (5.4.1) lib/sentry/hub.rb:59:in `with_scope'](http://localhost:3000/team/adir_report_templates#)
[sentry-ruby (5.4.1) lib/sentry-ruby.rb:352:in `with_scope'](http://localhost:3000/team/adir_report_templates#)
[sentry-ruby (5.4.1) lib/sentry/rack/capture_exceptions.rb:18:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/show_exceptions.rb:26:in `call'](http://localhost:3000/team/adir_report_templates#)
[railties (7.0.3.1) lib/rails/rack/logger.rb:40:in `call_app'](http://localhost:3000/team/adir_report_templates#)
[railties (7.0.3.1) lib/rails/rack/logger.rb:25:in `block in call'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/tagged_logging.rb:114:in `block in tagged'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/tagged_logging.rb:38:in `tagged'](http://localhost:3000/team/adir_report_templates#)
[activesupport (7.0.3.1) lib/active_support/tagged_logging.rb:114:in `tagged'](http://localhost:3000/team/adir_report_templates#)
[railties (7.0.3.1) lib/rails/rack/logger.rb:25:in `call'](http://localhost:3000/team/adir_report_templates#)
[sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/request_id.rb:26:in `call'](http://localhost:3000/team/adir_report_templates#)
[rack (2.2.4) lib/rack/method_override.rb:24:in `call'](http://localhost:3000/team/adir_report_templates#)
[rack (2.2.4) lib/rack/runtime.rb:22:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/executor.rb:14:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/static.rb:23:in `call'](http://localhost:3000/team/adir_report_templates#)
[rack (2.2.4) lib/rack/sendfile.rb:110:in `call'](http://localhost:3000/team/adir_report_templates#)
[actionpack (7.0.3.1) lib/action_dispatch/middleware/host_authorization.rb:137:in `call'](http://localhost:3000/team/adir_report_templates#)
[message_bus (3.3.8) lib/message_bus/rack/middleware.rb:61:in `call'](http://localhost:3000/team/adir_report_templates#)
[rack-cors (1.1.1) lib/rack/cors.rb:100:in `call'](http://localhost:3000/team/adir_report_templates#)
[rack-mini-profiler (2.3.2) lib/mini_profiler/profiler.rb:384:in `call'](http://localhost:3000/team/adir_report_templates#)
[webpacker (5.4.3) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'](http://localhost:3000/team/adir_report_templates#)
[rack-proxy (0.7.2) lib/rack/proxy.rb:67:in `call'](http://localhost:3000/team/adir_report_templates#)
[railties (7.0.3.1) lib/rails/engine.rb:530:in `call'](http://localhost:3000/team/adir_report_templates#)
[puma (4.3.12) lib/puma/configuration.rb:228:in `call'](http://localhost:3000/team/adir_report_templates#)
[puma (4.3.12) lib/puma/server.rb:727:in `handle_request'](http://localhost:3000/team/adir_report_templates#)
[puma (4.3.12) lib/puma/server.rb:476:in `process_client'](http://localhost:3000/team/adir_report_templates#)
[puma (4.3.12) lib/puma/server.rb:332:in `block in run'](http://localhost:3000/team/adir_report_templates#)
[puma (4.3.12) lib/puma/thread_pool.rb:134:in `block in spawn_thread'](http://localhost:3000/team/adir_report_templates#)
Took these steps to reproduce:
- Generated a new Rails application with
--minimal
, the Gemfile beginning with:
ruby "3.1.2"
gem "rails", "~> 7.0.3.1"
gem "i18n", "1.8.6"
Updated ApplicationController
to be:
class ApplicationController < ActionController::Base
def index
redirect_to "/show", notice: t("update.success", model: Diagnosis.model_name.human)
end
def show
end
end
Defined routes:
root to: "application#index"
get "/show", to: "application#show"
Defined translation:
en:
update:
success: "%{model} was updated successfully."
Defined a view to show the flash message.
Navigated to http://localhost:3000
. Saw the flash message appear. No exception.
Are you able to reproduce this issue within a new Rails app?
I have the same problem, my app has rails 7.0.4, ruby 3.0.4 and i18n 1.12.0. Any soluction for that?
It turned out one of our gems was using an earlier version of Ruby and code executed from within a block via that gem was causing this
Ok, I'm going to close this issue now.