I've recently done an rails and ruby upgrade, we don't have strong params in the app (I know it's legacy).
So the way it's done in the app we have the following
def all_params_permitted(this_params = nil)
this_params = params if this_params == nil
this_params.permit!
this_params.each do |i, v|
if v.kind_in?([Hash, ActionController::Parameters])
all_params_permitted(v)
end
end
end
Which loops through all params and just accepts everything, all_params_permitted
is called throughout the app I would love to add strong params but that's a no-go for now.
The issue in the above method is kind_in?
the upgrade I did for this app was rails 5.0.3
to rails 6.1+
and went from ruby 2.2.6
to ruby 3.0.1
so I'm not sure why kind_in?
has stopped working. This is an old app (built-in rails 2
) so not sure if this has been deprecated.
Any help here would be great.
Edit
I have tried kind_of?
but no dice.
Not sure about kind_in?
, also didn't find any reference to that method, also as you have not posted the error so not sure about your issue. is_a?
, kind_of?
, instance_of?
are few methods that check the object class but they check only a single class. Looking at your code one option for your condition could be:
if [Hash, ActionController::Parameters].include?(v.class)
which will check if it belongs to one of these classes.