as i know from the doc that in ActionController::Parameters, when you update a key with the operator []= and then use the permit method on the params, the key gets filtered even when we permit the key.
Is there any alternative way to update the key value to prevent this from happening? I need to do some checks and update that key but the permit method always filters out that key if I update it with []= method and value of that key becomes nil after updating.
an api temp_api in rails (with a key named foo coming from the api call with value "[null,\"hello\"]")
def temp_api
#preprocessing the key
if !params[:foo].nil?
foo = JSON.parse (params[:foo])
params[:foo] = foo - [nil,'']
end
p params[:foo] # correctly prints the new updated value
permitted_params = params.permit(:id,:foo)
p permitted_params[:foo] #this is printed nil (i want this to not get filtered)
# the foo column even shows as un permitted parameter in the server logs
p permitted_params[:id] #this is printed correctly if coming from the call
end
I basically want the foo column to not get filtered out if its updated
References i used already: https://api.rubyonrails.org/v6.1.0/classes/ActionController/Parameters.html#method-i-5B-5D-3D