我正在開發一個個人網站在軌道上的紅寶石。 我有一個表格被這樣動態生成:張貼表單提交獲取請求標題
<div>
<%= @request_type %>
<h1>Login Form</h1>
<% if @error == true %>
<h1>Error: Login Information Invalid</h1>
<% end %>
<%= form_for :user, url: {action: "login"}, method: :post do |f| %>
<p> E-mail: <br /> <%= f.text_field :email %></p>
<p> Password: <br /> <%= f.password_field :password %></p>
<p><%= submit_tag "Log In!", :disable_with => "Logging in..." %></p>
<% end %>
</div>
的@request_type
被設置爲request.request_method()
,用於調試目的的現在。
的HTML形式生成具體如下所示:
<form accept-charset="UTF-8" action="/login" method="post">
<!-- authentication token here -->
<p> E-mail: <br /> <input id="user_email" name="user[email]" type="text" /></p>
<p> Password: <br /> <input id="user_password" name="user[password]" type="password" /></p>
<p><input data-disable-with="Logging in..." name="commit" type="submit" value="Log In!" /></p>
</form>
然而,任何時候我提交,標題被設定與GET方法中,代替POST如在表格元素聲明(見method="post"
)。
R.O.R.可能與正在發生的事情無關...我使用Chrome來測試我的應用程序。有關爲何發生這種情況的任何想法?我絕對需要使用POST的請求。
如果有任何其他信息可能對解決此問題有用,請詢問,我會提供。
編輯:相關路線:
login POST /login(.:format) user#login
GET /login(.:format) user#login'
我看不出有任何理由張貼不與「登錄」行動相關的路由。
你可以做一個耙路線和後期的輸出? – 2014-11-04 05:57:20
@CaffeineCoder我已經發布了相關路線......我假設這就是你要找的東西?我可以發佈所有這些,如果你真的想... – Serge 2014-11-04 06:03:24
不,這沒關係。我想下面的答案顯示了代碼究竟有什麼問題。 – 2014-11-04 06:05:05