【发布时间】:2014-09-23 08:28:26
【问题描述】:
我正在尝试通过以下操作生成以引导程序为主题的脚手架:
将
gem 'twitter-bootstrap-rails'行添加到Gemfile的末尾并运行bundle install按照documentation 中的说明运行
rails generate bootstrap:install static将数据库帐户详细信息(用户名和密码)放在
database.yml文件的“默认”部分并运行rake db:create运行
rails g scaffold Purchase company_name:text product_name:text contact_person:text email:text comment:text运行 rake
db:migrate运行
rails g bootstrap:themed Purchases
每个命令都返回 0,所以我重新启动了一个网络服务器并转到 127.0.0.1:3000/purchases,但它看起来根本不使用 twitter 引导程序:
购买/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 %>
为什么?我究竟做错了什么?我该如何解决?
我正在使用 Ruby on Rails 4.1.4 顺便说一句。
【问题讨论】:
-
您是否为
application生成了布局? -
@mccannf 我该怎么做?通过运行命令 rails g bootstrap:layout [LAYOUT_NAME]?
-
@FrozenHeart 将此命令更改为
rails g bootstrap:themed Purchases至rails g bootstrap:themed Purchase,因为您需要将主题应用于您的模型 -
@anusha 也不行
-
Yes
rails g bootstrap:layout application并确认您要覆盖现有布局。 如果您想在整个应用程序中使用引导程序。
标签: ruby-on-rails ruby twitter-bootstrap ruby-on-rails-4 twitter-bootstrap-rails