Reputation: 15
I have a login form view for my rails app.
Login form code -
<h1>Log In</h1>
<%= form_tag dashboard_path do %>
<div class="field">
<%= label_tag :phone %><br>
<%= text_field_tag :phone %>
</div>
<div class="field">
<%= label_tag :password %><br>
<%= password_field_tag :password %>
</div>
<% end %>
<%= form tag sign_in_path do %>
<div class="actions">
<%= submit_tag "Log In"%>
</div>
<% end %>
So what I am trying here is that the submit button redirects to controller#action (sign_in_path) with phone
and password
as params that I entered in login page.
This login code is copied as I have zero html/angular knowledge also I am using jbuilder for rest of the views and not ERB.
UPDATE -
stdout
after first GET
request
Started GET "/dashboard" for 127.0.0.1 at 2019-11-27 11:29:49 +0530
Processing by HulksController#new as HTML
Rendering hulks/new.html.erb
Rendered hulks/new.html.erb (Duration: 1.0ms | Allocations: 590)
Completed 200 OK in 2ms (Views: 1.9ms | ActiveRecord: 0.0ms | Allocations: 1172)
stdout
after second post
request, after hitting the login button.
Started POST "/sign_in" for 127.0.0.1 at 2019-11-27 11:30:03 +0530
Processing by HulksController#create as HTML
Parameters: {"commit"=>"Log In"}
App 11639 output: {"commit"=>"Log In", "controller"=>"hulks", "action"=>"create"}
App 11639 output:
Completed 200 OK in 4ms (Views: 0.2ms | ActiveRecord: 0.6ms | Allocations: 1273)
Upvotes: 0
Views: 98
Reputation: 1026
There are two form_tag
in your example. Just change it to this:
<h1>Log In</h1>
<%= form_tag sign_in_path do %>
<div class="field">
<%= label_tag :phone %><br>
<%= text_field_tag :phone %>
</div>
<div class="field">
<%= label_tag :password %><br>
<%= password_field_tag :password %>
</div>
<div class="actions">
<%= submit_tag "Log In"%>
</div>
Upvotes: 2