我试图更新我的Representation属性ivpn& idirect(来自csv文件,通过rake任务,但我只是打印在这里只是程序的内容)并得到TypeError:
# in Rails Console:
representation = Representation.where(id: 977)
# => Representation_id: 977, ivnp: false, idirect: false
rows = Hash.[:ivpn => "", :idirect => "x"] # originally rows are coming from csv-file
representation.update_attributes! ivpn: rows.any?{|r| r[:ivpn].present?}, idirect: rows.any? {|r| r[:idirect].present?}
TypeError: can't convert Symbol into Integer
from (irb):42:in `[]'
from (irb):42:in `block in irb_binding'
from (irb):42:in `each'
from (irb):42:in `any?'
我在这里失踪了什么?
答案 0 :(得分:0)
试试这个:
representation.update_attributes! ivpn: rows.any?[{|r| r[:ivpn].present?}], idirect: rows.any? [{|r| r[:idirect].present?}]