2014-06-21 45 views
0

我剛升級我的應用程序到Rails 4,現在我的一些RSpec規格都失敗了,都是以同樣的方式。factory_girl導致RSpec規格在Rails 4升級後失敗

SQL (82.3ms) INSERT INTO "profiles" ("career_goal", "created_at", "email", "encrypted_password", "first_name", "gpa", "grad_year", "hidden", "keywords", "kind", "last_name", "major_names", "middle_name", "minor_names", "phone", "id", "research_interest", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["career_goal", ["Illum et sunt.", "Illo sapiente nesciunt reiciendis nulla fugit est autem."]], ["created_at", Sat, 21 Jun 2014 15:12:40 PDT -07:00], ["email", "[email protected]"], ["encrypted_password", "$2a$10$y1zijhGouDy1OT4qHGnXR./FvXP9T7DHHvu4BofAt5ZBJrqjFisty"], ["first_name", "Jayde"], ["gpa", #<BigDecimal:e684850,'0.25E1',18(36)>], ["grad_year", 2013], ["hidden", false], ["keywords", "Daisha Ea placeat debitis repellendus autem ad voluptas. Illum et sunt. Illo sapiente nesciunt reiciendis nulla fugit est autem. "], ["kind", "student"], ["last_name", "Reilly"], ["major_names", "Anthropology"], ["middle_name", "Daisha"], ["minor_names", "Sociology"], ["phone", "724-953-4023 x4372"], ["id", ""], ["research_interest", "Ea placeat debitis repellendus autem ad voluptas."], ["updated_at", Sat, 21 Jun 2014 15:12:40 PDT -07:00]] 

TypeError: can't cast Array to text: INSERT INTO "profiles" ("career_goal", "created_at", "email", "encrypted_password", "first_name", "gpa", "grad_year", "hidden", "keywords", "kind", "last_name", "major_names", "middle_name", "minor_names", "phone", "id", "research_interest", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 

它看起來像SQL調用現在是某種畸形的爲INSERT INTO "profiles" ("fields", etc) VALUES (?,?,?)任何有識之士,爲什麼VALUES部分是所有?的,將不勝感激。我檢查了我的定義:profile,它並不像我在其他地方讀過的那樣是Faker的問題。 (我有Faker::Lorem.words(4).join('-')這不給陣列或任何東西,這是一個活動記錄的問題嗎?是否有其他地方我應該尋找錯誤或需要重新配置的東西?

回答

0

問號不是問題;他們的佔位符值。

你的價值觀陣列的這部分

["career_goal", ["Illum et sunt.", "Illo sapiente nesciunt reiciendis nulla fugit est autem."]] 

表明career_goal被設置爲一個數組,將其更改爲一個字符串(與join或重寫它,無論)。

+0

感謝一羣,這工作! – user3579987

+0

哈哈,有勾號! – user3579987