我试图在更新对象之前从参数中删除一个属性,但我没有成功。
参数包含一个对象 Post,我想从中删除 image_url:
{
"post" : "{
\"content\" : \"dfsgdfa\",
\"created_at\" : \"2013-09-01T08:39:26Z\",
\"id\" : 21,
\"image_content_type\" : \"image/jpeg\",
\"image_file_name\" : \"img.jpg\",
\"image_file_size\" : 61140,
\"image_updated_at\" : \"2013-09-01T08:39:26Z\",
\"title\" : \"sdsdsdd\",
\"updated_at\" : \"2013-09-01T08:39:26Z\",
\"user_id\" : 4,
\"image_url\" : \"/system/posts/images/000/000/021/original/img.jpg?137802476
\"}",
"image" : "null",
"action" : "update",
"controller" : "posts",
"id" : "21"
}
所以我确实喜欢这样:
params[:post].delete("image_url")
没有引发错误,但 image_url 仍在 params[:post] 中
我怎样才能删除它?