2011-09-24 48 views
0

我的表單在本地似乎工作得很好,但是在heroku上給我一個語法錯誤。這裏是我的代碼多數民衆贊成導致錯誤:窗體在本地工作,而不是在heroku? Rails 3

<%= form_for (@item, {:url => [@company, @item]}) do |item_form| %> 

的錯誤是:

語法錯誤,意外 '}',期待keyword_end 2011-09-24T22:25:25 + 00:00的應用[ web.1]:... e,{:url => [@company,@item]})do | item_form | @output_buf ...

然後,當我試圖

<%= form_for (@item, :url => [@company, @item]) do |item_form| %> 

它給了我這個錯誤:

語法錯誤,意外 '',預計 ')' 2011-09-24T22:18 :01 + 00:00 app [web.1]:... ffer.append = form_for(@share,:url => [@company,@share])

任何想法?

回答

4

您應該刪除方法調用form_for和左括號(之間的空格。作爲一般規則,不要這樣做。這是含糊不清,並可能導致你與一個參數調用form_for解析器的思維,就像這樣:

<%= form_for((@item, :url => [@company, @item])) do |item_form| %> 

...這將是一個語法錯誤,導致您所看到的錯誤(如意外逗號)

# it should be: 
<%= form_for(@item, :url => [@company, @item]) do |item_form| %> 

# or, remove the parentheses altogether (up to your usage tastes): 
<%= form_for @item, :url => [@company, @item] do |item_form| %> 
+0

啊,多麼愚蠢的錯誤!謝謝! – Elliot

相關問題