What is the difference between form_for and form_tag?

1

What is the difference between form_for and form_tag in form construction since the end result is apparently the same?

In which situation do you choose one or the other?

    
asked by anonymous 12.12.2017 / 21:45

1 answer

1

form_for you use for a specific model, ex

<% form_for @user do |f|

<%= f.text_field :nome %>
<%= f.email_field :email %>
<%= f.submit %>
<% end %>

Form tag you use to create simple forms

<%= form_tag '/search' do %>
  <%= text_field_tag "q" %>
<% end %>
    
13.12.2017 / 13:21