Created
April 18, 2019 19:16
-
-
Save KonnorRogers/2c93cb18c65a42a4c9994c81f27eef5e to your computer and use it in GitHub Desktop.
form_for vs form_tag vs form_with params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= 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] %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= 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] %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= 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