【问题标题】:How do you indicate where the form_tag is submitted to in Rails?你如何在 Rails 中指明 form_tag 的提交位置?
【发布时间】:2009-05-12 22:41:55
【问题描述】:

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

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

在上面的例子中,这个表单是否从呈现这个视图的同一个控制器提交自己到“checkout_submit”操作?

【问题讨论】:

    标签: ruby-on-rails webforms controller


    【解决方案1】:

    如图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>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-19
    • 2014-01-09
    • 2015-10-16
    • 2021-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多