我已经建立了一个导入数据的任务,如下所示:
CSV.foreach(file, :headers => true) do |row|
question = Question.new ({
content: row[0],
mark: row[1],
topic_id: row[2],
question_type_id: row[3],
answers_attributes: [
{ content: row[5], correct: row[6] },
{ content: row[7], correct: row[8] }
]
})
question.user_id = row[4]
question.save!
这是我的 CSV 文件:
content, mark, topic_id, question_type_id, user_id, content, correct, content, correct
_____ are people involved in or affected by project activities, 5, 16, 1, 3, True, 't', False, 'f'
但是当我运行导入任务时,correct attribute
数据库中的总是 FALSE,我尝试过使用不同的 PostgreSQL布尔数据类型但没有工作。我错了什么?