Ruby on rails DataTables和Rails设置,但未显示任何更改
我已经按照以下教程在Rails应用程序中设置了DataTables,但我没有看到任何变化。以下是我遵循的原则: 我没有得到一个错误。我只是觉得没什么变化。我重新启动了服务器 Application.jsRuby on rails DataTables和Rails设置,但未显示任何更改,ruby-on-rails,ruby-on-rails-4,datatables,jquery-datatables,Ruby On Rails,Ruby On Rails 4,Datatables,Jquery Datatables,我已经按照以下教程在Rails应用程序中设置了DataTables,但我没有看到任何变化。以下是我遵循的原则: 我没有得到一个错误。我只是觉得没什么变化。我重新启动了服务器 Application.js //= require dataTables/jquery.dataTables Application.css *= require dataTables/jquery.dataTables 视图: 我只想能够对列进行排序。为什么不起作用?尝试将Products.js.coffee转换
//= require dataTables/jquery.dataTables
Application.css
*= require dataTables/jquery.dataTables
视图:
我只想能够对列进行排序。为什么不起作用?尝试将Products.js.coffee转换回常规javascript,看看结果是否相同。如果是这样,问题要么在于javascript本身,要么在于coffeescript的编译(确保CoffeeRails gem在gem文件中)。另外,请查看。您所说的“确保宝石在那里”是什么意思?这是coffeescript的一个gem还是datatables的另一个gem可以让它与coffeescript一起工作?是的,确保CoffeeRails gem在gem文件中。此外,在RailsCast/AsciCast的末尾还提到了其他调试技巧。我更新了答案,让它更清楚。
<table id="products">
<thead>
<tr>
<th>Name</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>Something</td>
<td>Something</td>
</tr>
<tr>
<td>Something</td>
<td>Something</td>
</tr>
<tr>
<td>Something</td>
<td>Something</td>
</tr>
</tbody>
</table>
jQuery ->
$('#products').dataTable