我正在按照 rails casts #340 在我的应用程序中实现数据表。
按照所有步骤我得到这个错误:找不到文件'dataTables/jquery.dataTables'
我正在使用 rails 4,我发现教程中提到的一些文件我必须创建,例如 application.css 和 products.js.coffee
宝石文件
gem 'jquery-rails'
group :assets do
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
gem 'jquery-ui-rails'
end
应用程序.js
//= require jquery
//= require dataTables/jquery.dataTables
//= require_tree .
应用程序.js.coffee
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require dataTables/jquery.dataTables
*= require_tree .
*/
和 rails 4 一样,我在 /layouts/application.html.erb 中添加了对样式表的调用
<%= stylesheet_link_tag 'application.css', media: 'all' %>
和 products/index.htm.erb
<table class="table table-normal" id="products" >
<thead>
<tr>
<td>Code</td>
<td>Name</td>
<td>Description</td>
<td>Price</td>
<td>Stock</td>
<td>Enabled</td>
<td>Company</td>
</tr>
</thead>
<tbody>
<% @products.each do |product| %>
<tr>
<td style="text-decoration: underline;"><%= link_to product.code, edit_product_path(product) %></td>
<td><%= product.name %></td>
<td><%= product.description %></td>
<td><%= product.price %></td>
<td><%= product.stock %></td>
<td><%= product.enabled %></td>
<td><%= product.company_id %></td>
</tr>
<% end %>
</tbody>
</table>
我在输出中收到此错误
找不到文件“dataTables/jquery.dataTables”(在 ....app/assets/stylesheets/application.css:6 中)
任何想法如何解决这个问题?提前致谢