I want to use the Bootstrap css to style a \"select\" box in a form in a Ruby on Rails app.
On the Bootstrap site, they give this as an example:
First of all, for bootstrap's form-control
class to work, you must add it to select
tag itself
Per apidoc of rails form select
select(object, method, choices = nil, options = {}, html_options = {}, &block)
you can add html class as
<%= f.select(:ampm, options_for_select([['AM', 1], ['PM', 2]]), {}, {class: "form-control"}) %>
or simply
<%= f.select :ampm, [['AM', 1], ['PM', 2]], {}, {class: "form-control"}) %>
This works for me:
<%= f.select :secretquestion, options_for_select([
["Select One", ""],
"Your nick name",
"your schoool name",
"your love name",
"your comapnay name",
"your favourite website"]),
{}, { class: "form form-group form-control" } %>