What is the difference in below 2 Rails ajax forms.
Form 1
<%= form_tag '/posts', remote: true do %>
<% end -%>
Form 2
<%= form_tag ('/posts', remote: true) do %>
<% end -%>
While Form 1 works without any problem the form with parenthesis (Form 2) cause the below syntax error when trying to view the page in browser.
/home/my_app/app/views/articles/new.html.erb:3: syntax error, unexpected ',', expecting ')'
...er.append= form_tag ('/posts', remote: true) do @output_buf...
... ^
/home/my_app/app/views/articles/new.html.erb:8: syntax error, unexpected keyword_ensure, expecting end-of-input
I am using Rails 4.0.1.
yes, i also suffered this problem. For some reason removing the space after form_for
method worked for me. So, this both will work.
<%= form_tag('/posts', remote: true) do %>
and
<%= form_tag '/posts', remote: true do %>