我是Rails的新手,我不确定如何指定form_tag提交的位置?
<% form_tag do %>
<%= submit_tag "checkout_submit" %>
<% end %>
对于上面的示例,此表单是否从呈现此视图的同一控制器提交给“checkout_submit”操作?
答案 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>