2011-06-02 31 views
2

在我的開發環境,這是Windows 7,Ruby1.9.2p180,一切工作正常。Rails 3,使用mongoid但語法錯誤得到生產

但是,在生產環境中,這是Ubuntu 10.04,使用rvm的Ree 1.8.7,下面的錯誤得到了產生。 (我用乘客的Apache模塊來運行應用程序。)

/home/randomapp/public_html/app/models/article.rb:14: syntax error, unexpected ':', expecting kEND field :user_id, type: Hash^
/home/randomapp/public_html/app/models/article.rb:15: syntax error, unexpected ':', expecting kEND field :username, type: String^
/home/randomapp/public_html/app/models/article.rb:16: syntax error, unexpected ':', expecting kEND field :title, type: String^
/home/randomapp/public_html/app/models/article.rb:17: syntax error, unexpected ':', expecting kEND field :content, type: String^
/home/randomapp/public_html/app/models/article.rb:18: syntax error, unexpected ':', expecting kEND field :display_content, type: String^

如果這些線有如下代碼

field :user_id, type: Hash 
    field :username, type: String 
    field :title, type: String 
    field :content, type: String 
    field :display_content, type: String 

假設上述各行發展做工精細,你認爲它可能是語法分析器的問題? 我該如何解決這個問題?

回答

8

您正在使用1.9.2哈希語法。如果你想運行在1.9.2和1.8.7然後試試這個:

field :user_id, :type => Hash 
field :username, :type => String 
field :title, :type => String 
field :content, :type => String 
field :display_content, :type => String 
+0

非常感謝你....我的應用終於完成了!祝你今天愉快 – user482594 2011-06-02 08:28:28