简体   繁体   中英

Form working locally, and not in heroku? Rails 3

My form seems to work perfectly fine locally, but gives me a syntax error on heroku. Here is my code thats causing the error:

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

The error is:

syntax error, unexpected '}', expecting keyword_end 2011-09-24T22:25:25+00:00 app[web.1]: ...e, {:url => [@company, @item]}) do |item_form| @output_buf...

Then when I tried

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

It gave me this error:

syntax error, unexpected ',', expecting ')' 2011-09-24T22:18:01+00:00 app[web.1]: ...ffer.append= form_for (@share, :url => [@company, @share])

Any ideas?

You should remove the space between the method call form_for and the opening parenthesis ( . As a general rule, never do this. It's ambiguous and may result in the parser thinking that you're calling form_for with one argument, like this:

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

... which would be a syntax error, resulting in the errors you're seeing (eg unexpected comma)

# 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| %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM