I have a model with one of the fields being serialise :config, JSON
.
it should permit any hash as a value. But I can't quite see a clean way to do it with strong_parameters
.
my current solution is:
def resource_params
p = params.require(:model)
config = dp.slice(:config).permit!
p.delete(:config)
[p.permit(:foo, :bar, ...).merge(config)]
end
To whitelist an entire hash of parameters, the permit! method can be used
params.require(:log_entry).permit!
And also
If you want to make sure that multiple keys are present in a params hash, you can call the method twice:
params.require(:token)
params.require(:post).permit(:title)
but I'm no expert on that matter.