I have this ajax call which sends a JSON -
$.ajax({
data: JSON_main_data,
url: '/daily_work_updates',
type: "POST",
success: function(data){
if (data ==true)
alert("Data saved successfully");
else
alert("Data not saved successfully");
},
dataType: 'JSON',
contentType : 'application/json'
});
When I try to save this to a database it needs to be whitelisted using strong parameters for rails 4.
This is the call to the StrongParamter function-
DailyWorkUpdate.new(daily_work_update_params)
The strongparameter method-
private
def daily_work_update_params
params.require(:save_daily).permit(:attr1)
end
This throws an error in the browser which says- undefined method `permit' for #ARRAY
This is the JSON sent to the controller-
{"save_daily"=>[{"attr1"=>"AGNE_WI_UCMS"}]}
I have been stuck here for long now. Any help would be appreciated.