你如何指出form_tag在Rails中的提交位置?

时间:2009-05-12 22:41:56

标签: ruby-on-rails webforms controller

我是Rails的新手,我不确定如何指定form_tag提交的位置?

<% form_tag do %>
<%= submit_tag "checkout_submit" %>
<% end %>

对于上面的示例,此表单是否从呈现此视图的同一控制器提交给“checkout_submit”操作?

1 个答案:

答案 0 :(得分:7)

the docs所示:

form_tag('/posts')
# => <form action="/posts" method="post">

form_tag('/posts/1', :method => :put)
# => <form action="/posts/1" method="put">

form_tag('/upload', :multipart => true)
# => <form action="/upload" method="post" enctype="multipart/form-data">

<% form_tag '/posts' do -%>
  <div><%= submit_tag 'Save' %></div>
<% end -%>
# => <form action="/posts" method="post"><div><input type="submit" name="submit" value="Save" /></div></form>