Open j-sieg opened 1 year ago
@j-sieg I don't see those warnings when running Devise tests on Ruby 2.7, can you show the code in your custom parameter sanitizer: app/models/user/parameter_sanitizer.rb
?
Maybe that's implemented in a way that's delegating as non-kwargs to Devise or something. Thanks!
@carlosantoniodasilva here's the code in app/models/user/parameter_sanitizer.rb
class User::ParameterSanitizer < Devise::ParameterSanitizer
def initialize(params, resource = nil)
# resource's class, resource's name, params
super(User, :user, params)
sign_up_defaults = [:name, :mobile_number]
account_update_defaults = [
:name,
:date_of_birth,
:mobile_number,
:avatar_url
]
# Omitted code
# I use `resource` here to push some fields depending on biz logic
permit(:sign_up, keys: sign_up_defaults)
permit(:account_update, keys: account_update_defaults)
end
end
@j-sieg thanks. I don't see anything wrong at a glance, I thought maybe the calling code could be passing a hash like this:
permit_options = { keys: [:foo, :bar] }
...
# permit_options is a hash in this sample
permit(:sign_up, permit_options)
If that was the case, then the calling code would have to be changed to actual kwargs:
permit(:sign_up, **permit_options)
But it doesn't seem to be the case... what's interesting is that this code from Devise hasn't changed since 2015 so I'm not sure I want to switch it back to a hash of options when kwargs are much clearer there. 🤔
Hello first time here
I'm using Devise 4.8.1 with Rails and I'm upgrading my Rails version to 7.0.4 When I ran the tests on my app, I get these deprecation warnings:
There were plenty of them, so I decided to
bundle open devise
. I edited the file, ran the tests on my app, and the deprecation warnings about theParameterSanitizer
were gone. I put what I wrote on this PR.