FrozenHeart
FrozenHeart

Reputation: 20746

Unable to create bootstrap-themed scaffold in Ruby on Rails

I'm trying to generate a bootstrap-themed scaffold via the following actions:

Every command returns 0, so I restarted a web-server and go to the 127.0.0.1:3000/purchases, but it looks like it doesn't use twitter bootstrap at all:

enter image description here

purchases/index.html.erb

<h1>Listing purchases</h1>

<table>
  <thead>
    <tr>
      <th>Company name</th>
      <th>Product name</th>
      <th>Contact person</th>
      <th>Email</th>
      <th>Comment</th>
      <th colspan="3"></th>
    </tr>
  </thead>

  <tbody>
    <% @purchases.each do |purchase| %>
      <tr>
        <td><%= purchase.company_name %></td>
        <td><%= purchase.product_name %></td>
        <td><%= purchase.contact_person %></td>
        <td><%= purchase.email %></td>
        <td><%= purchase.comment %></td>
        <td><%= link_to 'Show', purchase %></td>
        <td><%= link_to 'Edit', edit_purchase_path(purchase) %></td>
        <td><%= link_to 'Destroy', purchase, method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br>

<%= link_to 'New Purchase', new_purchase_path %>

Why? What am I doing wrong? How can I fix it?

I'm using Ruby on Rails 4.1.4 btw.

Upvotes: 4

Views: 833

Answers (1)

jkdev
jkdev

Reputation: 11728

Try these:

  1. Make sure the <table> tag has the class(es) required by Bootstrap. For example: <table class="table table-striped">.

  2. Also, the scaffold-generated styles in app/assets/stylesheets/scaffolds.scss might be interfering. Remove them and see what happens.

And as @anusha said in a comment, remember to use the singular form when you run the generator. For example: rails g bootstrap:themed Purchase, not Purchases.

Upvotes: 1

Related Questions