Joh*_*ohn 2 forms haml ruby-on-rails
在我将以下代码中的"form {:action =>"/ comments"}"替换为"form_tag('/ comments')"之后:
=form_tag('/comments')
%fieldset
%input.comment_input{ :name => "comment[comment]", :size => 60, :type => "text" }
%input{ :name => "comment[activity_id]", :type => 'hidden', :value => "#{activity.id}" }
%button.post_coment_btn{ :type => "submit", :formmethod => "post"} Add Comment
Run Code Online (Sandbox Code Playgroud)
然后我得到以下错误:
syntax error, unexpected keyword_ensure, expecting $end
Run Code Online (Sandbox Code Playgroud)
..在第18行,但包含上述文件的文件只有17行.我是否错误地使用了form_tag?
< - 更新 - >
使用form_tag执行@Ben Zhang所表明的只是我实际上想要转到'comments'控制器中的'create'动作:
=form_tag :action => 'create', :controller => 'comments' do
Run Code Online (Sandbox Code Playgroud)