I'm trying to permit either a hash with certain values or a nil value through strong parameters. I now have the following:
params.require(:parent).permit(child: [:attr1, :attr2])
If I call this action with:
{ "parent": { "child": nil }}
Rails does not permit the child parameter. (Unpermitted parameter: child
)
How do I convince rails that both nil
and a hash is permitted? I know you can allow nil values by doing:
params.require(:parent).permit(:child, child: [:attr1, :attr2])
But this also allows string values.