Skip to content

Instantly share code, notes, and snippets.

@KonnorRogers
Created April 18, 2019 19:16
Show Gist options
  • Save KonnorRogers/2c93cb18c65a42a4c9994c81f27eef5e to your computer and use it in GitHub Desktop.
Save KonnorRogers/2c93cb18c65a42a4c9994c81f27eef5e to your computer and use it in GitHub Desktop.
form_for vs form_tag vs form_with params
<%= form_for(:session, url: login_path) do |f| %>
<%= f.label :name %><br>
<%= f.text_field :name %><br>
<%= f.submit "Login" %>
<% end %>
<%# To access the params in your controller its simply: %>
<%# params[:session][:name] %>
<%= form_tag login_path do |form| %>
<%= label_tag :name %><br>
<%= text_field_tag :name %><br><br>
<%= submit_tag "Login" %><br>
<% end %>
<%# To access the params in your controller its simply: %>
<%# params[:name] %>
<%= form_with(url: login_path) do |form| %>
<%= form.label :name %><br>
<%= form.text_field :name %><br>
<%= form.submit "Login" %>
<% end %>
<%# To access the params in your controller its simply: %>
<%# params[:name] %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment