Drekoo
Drekoo

Reputation: 43

I can't load bootstrap to my form Rails

I can't load bootstrap sass to my form in users/new.html.erb In railstutorial.org in listing 7.15 / 7.16 it looks like this: 1`1 enter image description here

For me it looks like this: enter image description here

My repository: https://github.com/xt442/railstutorialorg

Thanks for help!!

Upvotes: 1

Views: 41

Answers (2)

Salil
Salil

Reputation: 47542

you have to wrap the label & text field with the div with class form-group. & for button to span over the entire width of the parent element use class btn-block

Something like following

<%= form_for(@user) do |f| %>
  <%= content_tag :div, class: 'form-group' do %>
    <%= f.label :name %>
    <%= f.text_field :name, class: 'form-control' %>
  <% end %>
  <%= content_tag :div, class: 'form-group' do %>
    <%= f.label :email %>
    <%= f.email_field :email, class: 'form-control' %>
  <% end %>
  <%= content_tag :div, class: 'form-group' do %>
    <%= f.label :password %>
    <%= f.password_field :password, class: 'form-control' %>
  <% end %>
  <%= content_tag :div, class: 'form-group' do %>
    <%= f.label :password_confirmation, "Confirmation" %>
    <%= f.password_field :password_confirmation, class: 'form-control' %>
  <% end %>
  <%= f.submit "Create my account", class: "btn btn-primary btn-block" %>
<% end %>

Upvotes: 2

Pietro Allievi
Pietro Allievi

Reputation: 436

don't know if it could fix, but I notice you've missed params partial:

<%= render partial:'layouts/header' %>

and

<%= render partial:'layouts/footer' %>

that should work

Upvotes: 0

Related Questions