Is it possible to tag one hash attribute as needed using strong parameters?
This input is as:
{
"example" => {
"optional": 1234,
"required": 5678
}
}
Standard examples of strong parameters are:
params.require(:example).permit(:optional, :required)
Given that you may require certain parameters, I thought the following would work:
params.require(:example).require(:required)
params.require(:example).permit(:optional)
I tried:
params.require(:example => [ :required ]).permit(:optional)
params.require(:example).permit(:optional)
params[:example].require(:required)
And all that I can come up with.
Does anyone know if this is possible?
source
share