如何將我寫強PARAMS這個JSON,如果我有地圖模型,其中我想保存這些記錄:如何寫字符串params用於在JSON在軌道4,5
{
"map":[
{"lat": "51.088672", "lon": "71.396522", "vibration_level": "300", "time_sent": "07:25:00"},
{"lat": "51.088672", "lon": "71.396453", "vibration_level": "300", "time_sent": "07:25:01"},
{"lat": "51.088829", "lon": "71.396476", "vibration_level": "300", "time_sent": "07:25:14"}
]
}
我已經嘗試過類似的東西:
params.require(:map).permit(:lat, :lon, :vibration_level, :time_sent)
params.permit(map: [:lat, :lon, :vibration_level, :time_sent])
params.permit(map: [:lat, :lon, :vibration_level, :time_sent]).require(:maps)
您的'JSON params'看起來不對。你確定這些是正確的嗎? – Pavan
@Pavan,我在JSONlint.com檢查 – yerassyl
嘗試'params.permit({map:[:lat,:lon,:vibration_level,:time_sent]})' – Pavan