deprecation warning: resource received a hash argument * Please use a keyword instead
Environment
- Ruby 3.3.3
- Rails 8.1.0.alpha
- Devise 4.9.4
Current behavior
Strangely enough this only is reported in test ?!
√ bellis % rails test test/services/dinero_service_test.rb
DEPRECATION WARNING: resource received a hash argument only. Please use a keyword instead. (called from block in <main> at /Users/walther/Deling/Walther/src/mortimer/redbox/bellis/config/routes.rb:4)
DEPRECATION WARNING: resource received a hash argument path. Please use a keyword instead. (called from block in <main> at /Users/walther/Deling/Walther/src/mortimer/redbox/bellis/config/routes.rb:4)
DEPRECATION WARNING: resource received a hash argument path_names. Please use a keyword instead. (called from block in <main> at /Users/walther/Deling/Walther/src/mortimer/redbox/bellis/config/routes.rb:4)
DEPRECATION WARNING: resource received a hash argument controller. Please use a keyword instead. (called from block in <main> at /Users/walther/Deling/Walther/src/mortimer/redbox/bellis/config/routes.rb:4)
DEPRECATION WARNING: resource received a hash argument only. Please use a keyword instead. (called from block in <main> at /Users/walther/Deling/Walther/src/mortimer/redbox/bellis/config/routes.rb:4)
DEPRECATION WARNING: resource received a hash argument path. Please use a keyword instead. (called from block in <main> at /Users/walther/Deling/Walther/src/mortimer/redbox/bellis/config/routes.rb:4)
DEPRECATION WARNING: resource received a hash argument path_names. Please use a keyword instead. (called from block in <main> at /Users/walther/Deling/Walther/src/mortimer/redbox/bellis/config/routes.rb:4)
DEPRECATION WARNING: resource received a hash argument controller. Please use a keyword instead. (called from block in <main> at /Users/walther/Deling/Walther/src/mortimer/redbox/bellis/config/routes.rb:4)
Running 5 tests in a single process (parallelization threshold is 50)
Run options: --seed 28000
The warnings go away if I comment this in config/routes.rb
devise_for :users, controllers: {
invitations: "users/invitations",
registrations: "users/registrations",
sessions: "users/sessions",
confirmations: "users/confirmations",
passwords: "users/passwords",
unlocks: "users/unlocks",
omniauth_callbacks: "users/omniauth_callbacks"
}
Cannot find anything on SO and neither in the Devise repo ?
Not sure what keyword I should use - trying to follow Devise documented config
* controllers: the controller which should be used. All routes by default points to Devise controllers.
However, if you want them to point to custom controller, you should do:
devise_for :users, controllers: { sessions: "users/sessions" }
My wrong doing ?
Expected behavior
I would not expect any deprecation warnings at all (eg. none seen when running dev )
This was appearing for me too.
Pointing at Devise main branch (5.0.0.beta) in my Gemfile resolved the deprecation warnings.
gem 'devise', github: 'heartcombo/devise', branch: 'main'
This seems to be an issue with final release Rails 8.1.0 which is out now, and latest devise release (which seems to be 4.9.4), yes?
Quite inconvenient. Any chance of a quick small release that fixes?
@jrochkind no chance of a quick small release since there's been other fixes on main that target Rails 8+, but I'm planning a new v5 release soon.
I've successfully upgraded one mature application to Rails 8.1 and current Devise main branch. So far in my tests it works perfect.
It would be nice to have a beta pre-release published as a gem. It would help to test things out (installing directly from git sometimes can be discouraged)
@Envek definitely agree, working on it... haven't released one yet because there's some commits I need to bring in to master from a previous 5-rc branch: https://github.com/heartcombo/devise/issues/5736#issuecomment-3496836234, but hopefully soon... ™️
Thanks for trying it out and reporting back!
I keep getting the same warning on Rails 8.1.1, and since we’re using Devise JWT, we can’t use the beta version of the main branch. Please fix.
For now, adding config.active_support.report_deprecations = false in our test environment configuration suppresses the warnings whenever we run our test suite.