1
votes

I am building a simple_form in a rails app I am building. I have the bootstrap-sass gem installed and it is working. I am attempting to add bootstrap styles to my form. I've done this before, so I'm a bit confused as to why this is not working. Have I done something wrong? Bootstrap is adjusting my overall div size, but none of the styles for the form get applied. Help would be appreciated.

<%= simple_form_for @album do |f| %>
<div class="form-group">
 <%= f.input :title, class: 'form-control' %>
</div>
<div class="form-group">
<%= f.input :artist, class: 'form-control' %>
</div>
<div class="form-group">
  <%= f.input :year, class: 'form-control'  %>
</div>
<%= f.file_field :cover %> 
 <br />
 <%= f.button :submit %>
<% end %>
1

1 Answers

0
votes

You should try inspecting the element in your browser to debug: Right click on the element and select "Inspect element".

The issue here is that your form-control class is not applied to the input. To achieve that you have to change

<%= f.input :title, class: 'form-control' %>

to

<%= f.input :title, input_html: { class: 'form-control' } %>

Do read up on the simple_form documentation to understand how to use it.