我注意到我的应用程序自动将所有进程设置为在创建完成后立即完成。我翻遍了它,找不到为什么日期没有被告知更新,但我发现我的一个观点是寻找一个不存在的领域。我创建了'完整'字段,将其设置为非空布尔值并再次尝试。rails列不能为空:
我正在将它自动设置为true,所以我试图在创建方法中将它设置为false,但仍然无法工作:S因此我试图将隐藏的字段放入表单中。即使提供了值,我现在也会得到“列不能为空”的错误。
正如你所看到的,显然有一个完整值的参数。我错过了什么?
错误:
Mysql::Error: Column 'complete' cannot be null: INSERT INTO `decommissions` (`completed_at`, `keep_backups`, `services_stopped`, `updated_at`, `operating_system_id`, `comments`, `username`, `disposition`, `stakeholder_email`, `complete`, `alias`, `storage`, `model_id`, `contract_maintenance`, `created_at`) VALUES(NULL, 1, 1, '2010-10-18 00:32:37', 1, NULL, NULL, '', '[email protected]', NULL, 'test1', '', 1, '', '2010-10-18 00:32:37')
参数:
{"decommission"=>{"dns_items_attributes"=>{"0"=>{"ip"=>"131.181.185.111",
"alias"=>"test",
"retain"=>"1",
"_destroy"=>""}},
"keep_backups"=>"1",
"services_stopped"=>"1",
"operating_system_id"=>"1",
"stakeholder_email"=>"[email protected]",
"alias"=>"test1",
"model_id"=>"1"},
"commit"=>"Submit",
"authenticity_token"=>"cMMf0zS/5jPExlXqVPaYVXndqPeVkm+OQ/WEPIYd2+g=",
"disposition"=>"Dispose",
"complete"=>"false",
"storage"=>"Local",
"contract_maintenance"=>"0"}
当我把我的创建控制器它呈现 '真' 下面:
@decommission = Decommission.new(params[:decommission])
@decommission.complete = false
render :text => @decommission.complete
是在你的*退役*迁移'complete'列类型一个'boolean'? – 2010-10-18 00:59:23
是的,我也测试过使用tinyints代替'false',但那也不起作用 – Rumpleteaser 2010-10-18 01:14:47
您的模型有一个名为'complete'的方法吗? – zetetic 2010-10-18 04:13:34