我正在使用 rails 4.2.4,在生成基本产品脚手架后,我似乎无法获得 gem jquery-datatables-rails。我正在使用 github 自述文件和 railscast 剧集来尝试让它完全没有运气。
http://railscasts.com/episodes/340-datatables
https://github.com/rweng/jquery-datatables-rails
宝石文件
gem 'jquery-datatables-rails', '~> 3.3.0'
应用程序.js
//= require jquery
//= require jquery_ujs
//= require dataTables/jquery.dataTables
//= require turbolinks
//= require_tree .
jQuery -> $('.datatable').DataTable();
应用程序.css
*= require dataTables/jquery.dataTables
*= require_tree .
*= require_self
index.html.erb
<table class="datatable">
<thead>
<tr>
<th>Name</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<% @products.each do |product| %>
<tr>
<td><%= product.name %></td>
<td><%= product.price %></td>
</tr>
<% end %>
</tbody>
</table>
我尝试在我的 gemfile 中直接引用 github repo。生成安装似乎没有以任何方式正确添加需求,所以我手动将它们放入。