我建立了一個任務可以導入這樣的數據:無法設置布爾值,當從CSV導入數據到PostgreSQL
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的Boolean Data Type,但是沒有工作。我錯了什麼?
請向我們展示(生成的)SQL。我看起來像't'和'f'字段是多餘的/多餘的。 – wildplasser
@DipakPanchal它有錯誤:'第2行非法引用。' @wildplasser當我使用'rake import'時,如何顯示SQL? – Thanh
結果不變,兩個答案行仍然有正確的值是'FALSE' – Thanh