下拉表单显示在页面上,但类别只是笨拙地漂浮在其下方,单击下拉表单没有任何作用。如果我从下拉表单中取出引导程序,那么它可以完美地工作,但它是一个丑陋的默认版本。
_form.html.erb
<form>
<select class="form-control">
<%= f.collection_select :categories, Value::VALUES, :to_s, :to_s, :include_blank => true, class: 'form-control', placeholder: 'Choose Category' %>
</select>
</form>
value.rb 模型
class Value < ActiveRecord::Base
belongs_to :user
VALUES = ['Courage', 'Determination', 'Gratitude', 'Humor']
end
整个表格
<%= form_for(@value) do |f| %>
<% if @value.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@value.errors.count, "error") %> prohibited this value from being saved:</h2>
<ul>
<% @value.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="america">
<form>
<div class="form-group">
<%= f.text_field :name, class: 'form-control', placeholder: 'Enter Value' %>
</div>
<select class="form-control">
<%= f.collection_select :categories, Value::VALUES, :to_s, :to_s, :include_blank => true, class: 'form-control', placeholder: 'Choose Category' %>
</select>
<%= button_tag(type: 'submit', class: "btn") do %>
<span class="glyphicon glyphicon-plus"></span>
<% end %>
<%= link_to values_path, class: 'btn' do %>
<span class="glyphicon glyphicon-chevron-left"></span>
<% end %>
<%= link_to @value, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn' do %>
<span class="glyphicon glyphicon-trash"></span>
<% end %>
</form>
</div>
<% end %>