2014-01-18 32 views
0

我試圖通過創建一個標籤:創建通過命令行中的Rails記錄 - 不知道這個錯誤

[14] pry(main)> Tag.create! {"phrase" => "here is my phrase" } 
SyntaxError: unexpected tASSOC, expecting '}' 
Tag.create! {"phrase" => "here is my phrase" } 
         ^
[14] pry(main)> d = {"phrase" => "here is my phrase"} 
=> {"phrase"=>"here is my phrase"} 
[15] pry(main)> Tag.create! d      ^

我不知道什麼是錯的,但我不能得到這個工作做。任何想法我做錯了什麼?

THX

回答

0

其實你忘了支架 嘗試

Tag.create!({ 「短語」=> 「這裏是我的那句」})

+0

是的,看起來reasonab也可以,但我認爲它需要作爲一個arg而不是散列。我真的很驚訝。 – timpone

0

試試這個

Tag.create {:phrase =>「這裏是我的短語」}

+0

我認爲它需要作爲參數而不是散列。原本以爲這會工作。 – timpone