使用 bootstrap_form_for gem 将如何改变以下内容?
How would the following change using the bootstrap_form_for gem?
## 我不确定如何在下面的旧代码片段中重写 :action=> 标记以使用 boostrap_form_for 上下文。有人可以帮忙吗?
<%= form_tag(:action => 'attempt_login') do %>
<%= error_messages_for(@user) %>
<table>
<tr>
<th>email</th>
<td><%= email_field_tag(:email) %></td>
</tr>
<tr>
<th>password</th>
<td><%= password_field_tag(:password) %></td>
</tr>
</table>
<div class="frm-button">
<td><%= submit_tag("login") %></td>
</div>
<% end %>
改用url: ''
。如果您无法找到正确的 url、运行 rake routes
并在其中搜索您的操作。
你的 routes.rb
中应该有这样的东西:
match '/attempt_login', to: 'login_controller#attempt_login', via: :post
然后编辑您的表格:
<%= bootstrap_form_for(url: '/attempt_login', method: :post) do |f| %>
...
<% end %>
希望对您有所帮助。
## 我不确定如何在下面的旧代码片段中重写 :action=> 标记以使用 boostrap_form_for 上下文。有人可以帮忙吗?
<%= form_tag(:action => 'attempt_login') do %>
<%= error_messages_for(@user) %>
<table>
<tr>
<th>email</th>
<td><%= email_field_tag(:email) %></td>
</tr>
<tr>
<th>password</th>
<td><%= password_field_tag(:password) %></td>
</tr>
</table>
<div class="frm-button">
<td><%= submit_tag("login") %></td>
</div>
<% end %>
改用url: ''
。如果您无法找到正确的 url、运行 rake routes
并在其中搜索您的操作。
你的 routes.rb
中应该有这样的东西:
match '/attempt_login', to: 'login_controller#attempt_login', via: :post
然后编辑您的表格:
<%= bootstrap_form_for(url: '/attempt_login', method: :post) do |f| %>
...
<% end %>
希望对您有所帮助。