What is difference between form_for and form_tag?


The many answers of this question are not appropriated for me.
What is the BIG difference between form_for and form_tag?

In several web pages, i read like below…
form_for method is used for specificated wrapped model object,
and form_tag is just output the tag.
It’s not clear to me…

Isn’t it equal that source using form_for or form_tag?

Please, any feedback to me.


You would use form_for for a specific model when you want to create a
new row, like this

<% form_for :person, @person, :url => { :action => “update” } do |f| %>

then in here you can use the f object to create input field.

First name: <%= f.text_field :first_name %>
Last name : <%= f.text_field :last_name %>
Biography : <%= f.text_area :biography %>

<% end %>

Form_tag create basically just <form …>, can be used to create
multi form or whatever speciale thing you want to create.

<% form_tag ‘/posts’ do -%>
<%= text_field_tag “post”, “first_name” %>
<% end -%>