I have set these strong params:
def my_model_params
params.require(:my_model).permit(:field)
end
But sometimes the form is sent empty and I get this error:
param is missing or the value is empty: my_model
How can I allow the form to be empty when still using strong params?
Use
fetch.The reason you want to use this over
params.permit(my_model: [ :field ])is that it will always return anActionController::Parametersinstance instead of nil.