Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Simple Forms and Twitter Bootstrap 3

I'm having a lot of problems getting Simple Forms to work with Twitter Bootstrap 3 in the build a simple Ruby application project. The closest I've been able to get to being correct is by adding the following initializer file to my simple forms initializers. I just added this file in with all the others. https://gist.github.com/tokenvolt/6599141

However I still can't get the field labels to show up on the left side of the field. Has anyone been able to figure out how to get this to work?

My _form.html.erb file is listed below. I changed the markup to reflect the simple form documentation and not what was shown in the video as they are different now. https://github.com/plataformatec/simple_form

<%= simple_form_for @status, defaults: { input_html: { class: 'form-horizontal' } } do |f| %>
  <% if @status.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@status.errors.count, "error") %> prohibited this status from being saved:</h2>

      <ul>
      <% @status.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <%= f.input :content %>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

1 Answer

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Drew Bumpas as far as I know, Simple Form hasn't been updated specifically to work with bootstrap 3 yet. However, that gist you linked has some updates since you posted it. Maybe give that a try?

Thanks Jason, I actually just moved ahead and worked the CSS myself instead of using the Bootstrap classes. I appreciate the help!