Ruby on rails_format form fields with bootstrap

86 views Asked by At

I want to format form fields with Boostrap CSS.

I have following code in form view file:

<p>
  <%= f.label :country %>
  <%= f.select :country, ["India","USA","Australia"] %>
</p>

I want it to format as:

<select class="form-control">
    <option>India</option>
    <option>USA</option>
    <option>Australia</option>
</select>

I have tried few different ways that I thought would work, but no success.

1

There are 1 answers

0
Arslan Ali On BEST ANSWER
<%= f.select :country, options_for_select(["India", "USA", "Australia"]), class: "form-control" %>

It will generate the desired output.