Я следовал за Railscasts для построения DataTable по адресу: http://railscasts.com/episodes/340-datatables?autoplay=trueDataTables Не Включение в Rails - установка трубопровода собственно активов
После всех шагов, таблица по-прежнему делает то же самое, как и раньше, статический HTML:
Я использую bootstrap со многими другими драгоценными камнями ранее, но datatables добавили бы выделение в удобство использования приложения.
Я отправил код, который я в настоящее время использую,
Что может быть не так? Есть ли способ отладить javascript в приложении rails вместо того, чтобы делать что-то слепо?
manage.html.erb (Примечание: в местах просмотра папки):
<% if @restaurant.locations.any? %>
<h1>Manage <%= @restaurant.name.pluralize %> Restaurant Locations</h1>
<table id="restaurantLocations">
<thead>
<tr>
<th>Store Number</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Nearest Bidding City</th>
<th>Zip Code</th>
<th>Sit Down?</th>
<th>Drive Through?</th>
</tr>
</thead>
<%# current_user.locations.each do |branch| %>
<tbody>
<% @restaurant.locations.each do |branch| %>
<tr>
<td><%= branch.store_number %></td>
<td><%= branch.address %></td>
<td><%= branch.city_name %></td>
<td><%= branch.state.upcase %></td>
<td><%= Metro.where(id: branch.city_id).pluck(:city).first %></td>
<td><%= branch.zip %></td>
<td><%= branch.sit_down %></td>
<td><%= branch.drive_through %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<h1>Upload <%= @restaurant.name.pluralize %> Restaurant Locations</h1>
<p>Simply format your CSV file as the sample:(INSERT EXAMPLE) and upload</p>
<% end %>
<h2>Import Restaurants</h2>
<%= form_tag import_locations_path(id: @restaurant.id), multipart: true do %>
<%= file_field_tag :file %>
<%= submit_tag "Import" %>
<% end %>
application.js:
//= require jquery
//= require jquery_ujs
//= require chosen-jquery
//= require bootstrap
//= require dataTables/jquery.dataTables
//= require dataTables/bootstrap/2/jquery.dataTables.bootstrap
//= require turbolinks
//= require bootstrap-datepicker
//= require raphael
//= require morris
//= require underscore
//= require gmaps/google
//= require_tree .
applcation.css:
*
*= require_self
*= require chosen
*= require bootstrap-datepicker
*= require dataTables/jquery.dataTables
*= require dataTables/bootstrap/2/jquery.dataTables.bootstrap
*= require_tree .
*/
локаций. js.coffee:
jQuery ->
$("#restaurantLocations").dataTable();
Gemfile:
# DataTables
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'