Rails 4. PSQL 9.3。託管在Heroku上。我用angularJS發送我的數組。無法保存軌道活動模型中的整數數組...爲什麼?
在我的heroku服務器上,我檢查我的日誌,實際上params是作爲一個數組發送的。此外,我可以確認它是路由到適當的update
路線。這裏是英雄日誌:
INFO -- : Parameters: {"profile"=>{"order"=>[0, 1, 2, 3, 4]}, "id"=>"123"}
儘管正確地發送參數,Rails將不會保存此數組在我的activerecord。爲什麼?通過db migration
add_column :profiles, :order, :integer, array: true
我更新路由加入
的整數數組,像這樣:
def update
@profile = Profile.find(params[:id])
if @profile.update(profile_params)
render json: @profile
else
render 'failed to update'
end
end
,我定義profile_params爲:
def profile_params
params.require(:profile).permit(...some other variables, :order)
end
一切都非常標準的東西所以我不知道我做錯了什麼
使用angularJS前端側我有以下幾點:
var params = {
profile:{
order: [0,1,2,4]
}
}
$http.put("http://my_server_url/123", params)
.success(function(data,status,headers,config){
console.log(data)
})
任何想法,我做錯了什麼?
編輯:想通了什麼錯誤,仍然需要幫助
所以做了一些測試後,我發現,當我檢查profile_params它是空的。數組發送時爲什麼是空的?