compile error
D:/Ruby187/myTest/depot/app/views/store/index.html.erb:23: syntax error, unexpected ')'
..._cart" , :id => product } do ).to_s)
^
D:/Ruby187/myTest/depot/app/views/store/index.html.erb:28: syntax error, unexpected kEND, expecting ')'
; end ; @output_buffer.concat "/n/n/n"
^
D:/Ruby187/myTest/depot/app/views/store/index.html.erb:32: syntax error, unexpected kENSURE, expecting ')'
D:/Ruby187/myTest/depot/app/views/store/index.html.erb:34: syntax error, unexpected kEND, expecting ')'
Extracted source (around line #23):
20: <!-- form请求,<%= button_to "Add to Cart" ,:action => 'add_to_cart',:id => product%> -->
21:
22: <!-- Ajax请求 -->
23: <%= form_remote_tag :url => {:action => "add_to_cart" , :id => product } do -%>
24: <%= submit_tag "Add to Cart"%>
25: <% end -%>
26: </div>
这个错误信息的原因是因为store/index.html.erb:
我在其api中查询到:
# Generates:
# <form action="/" method="post" onsubmit="new Ajax.Request('/',
# {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)});
# return false;"> <div><input name="commit" type="submit" value="Save" /></div>
# </form>
<% form_remote_tag :url => '/posts' do -%>
<div><%= submit_tag 'Save' %></div>
<% end -%>
[Source]
细心的读者已经看到错误的原因了,是的,就是因为那个“=” ,我们只要把它去掉就可以了,正确的代码如下: