我正在使用Rails 4,Bootstrap 3和Simple_form,由于某种原因,“提交”按钮不提交任何内容。它甚至没有在服务器输出中生成任何东西供我调试。
这是我的代码:
<%= simple_form_for(@schedule) do |f| %>
<% if @schedule.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@schedule.errors.count, "error") %> prohibited this schedule from being saved:</h2>
<ul>
<% @schedule.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<form class="form-inline" role="form">
<div class="form-group">
<%= f.input :rating, collection: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] %>
</br>
<%= f.input :thought, :input_html => {:rows => 10, :cols => 85} %>
</div>
</form>
<div class="actions">
<%= f.button :submit, "Create", :class => 'btn btn-primary'%>
</div>
<% end %>
这是我的模特:
class Schedule < ActiveRecord::Base
validates :rating, :presence => true
validates :thought, :presence => true
end
我确信这很简单,但我完全被难倒了。
提前致谢。
答案 0 :(得分:2)
删除此
<form class="form-inline" role="form"> # <--- this another form begin
<div class="form-group">
<%= f.input :rating, collection: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] %>
</br>
<%= f.input :thought, :input_html => {:rows => 10, :cols => 85} %>
</div>
</form> # <--- this another form end
此代码以两种不同的形式将您分开。