【问题标题】:Form working locally, and not in heroku? Rails 3表格在本地工作,而不是在heroku?导轨 3
【发布时间】:2011-09-25 06:35:16
【问题描述】:

我的表单似乎在本地工作得很好,但是在 heroku 上给了我一个语法错误。这是导致错误的代码:

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

错误是:

语法错误,意外的“}”,需要keyword_end 2011-09-24T22:25:25+00:00 app[web.1]: ...e, {:url => [@company, @item]}) 做 |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])

有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 heroku


    【解决方案1】:

    您应该删除方法调用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| %>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-07
      • 2014-03-20
      相关资源
      最近更新 更多