views:

552

answers:

1

I'm new to Rails and am not sure how to specify where the form_tag submits to?

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

In the case of the example above, does this form submit itself to the "checkout_submit" action from the same controller that rendered this view?

+5  A: 

As illustrated in 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>
Chuck
Thanks for the docs link. That certainly makes things easier.
cambra