Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用列类型为数组的update_属性_Ruby On Rails_Arrays_Postgresql_Ruby On Rails 4_Updatemodel - Fatal编程技术网

Ruby on rails 使用列类型为数组的update_属性

Ruby on rails 使用列类型为数组的update_属性,ruby-on-rails,arrays,postgresql,ruby-on-rails-4,updatemodel,Ruby On Rails,Arrays,Postgresql,Ruby On Rails 4,Updatemodel,我有一个语言列,它是一个字符串数组,带有 add_column :table, :languages, :string, array: true, default: [] 当我在该模型上使用update\u attributes时,除了保留的[]languages列之外,所有列都将被更新 这里有什么特别需要做的吗?当您将数组发布到控制器中的操作上时,您应该允许这样做: params.require(:table).permit( {:languages => []}, :other_fi

我有一个语言列,它是一个字符串数组,带有

add_column :table, :languages, :string, array: true, default: []
当我在该模型上使用
update\u attributes
时,除了保留的
[]
languages列之外,所有列都将被更新


这里有什么特别需要做的吗?

当您将数组发布到控制器中的操作上时,您应该允许这样做:

params.require(:table).permit( {:languages => []}, :other_field, :other_field2... )

表参数中允许使用语言它允许作为数组吗?这种权限只允许使用空数组我从我的应用程序复制/粘贴了它,它工作得很好。。。它告诉控制器允许语言作为一个数组,而不是一个空的数组。