我看了很多東西有關此錯誤:Rails的 - 無法大規模指派保護屬性
WARNING: Can't mass-assign protected attributes: contact_id, country_id, winery
但我不明白爲什麼它出現了。我使用Rails 3.0.5(並且不想在當時切換到3.1)。
我的日誌:
Started POST "/ws/webapp/services/push_item" for 127.0.0.1 at Thu Mar 01 18:45:16 +0100 2012
Processing by Webapp::ServicesController#push_item as JSON
Parameters: {"wine"=>{"contact_id"=>"<null>", "country_id"=>"1", "id"=>"3FAE414B-97B2-4C05-8A02-8AAC3F3B89F6", "winery"=>"New wine"}, "authenticity_token"=>"Da/2MDivaxxmS1zb7x6EK63xARnd/RrpmFoWtsOHock=", "locale"=>"ws"}
Wine Load (0.4ms) SELECT `wines`.* FROM `wines` WHERE `wines`.`id` = '3FAE414B-97B2-4C05-8A02-8AAC3F3B89F6' AND `wines`.`user_id` = 1 LIMIT 1
WARNING: Can't mass-assign protected attributes: contact_id, country_id, winery
3FAE414B-97B2-4C05-8A02-8AAC3F3B89F6
SQL (0.2ms) BEGIN
SQL (0.2ms) ROLLBACK
Completed 200 OK in 245ms (Views: 6.1ms | ActiveRecord: 9.5ms)
所以請求(更新)不起作用。 3個字段contact_id,country_id,winery位於我的數據庫中。
有什麼想法?
確定。 這些問題似乎是因爲我在參數中發送了wine [:id]。我現在只發:從葡萄酒參數中出來,沒關係。 – 2012-03-01 19:52:20