2016-02-23 60 views
0

我已经正确编写的代码,但我的数据表是不工作数据表中的Rails应用程序无法正常工作

// This is a manifest file that'll be compiled into application.js, which will include all the files 
 
// listed below. 
 
// 
 
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 
 
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 
 
// 
 
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 
 
// compiled file. 
 
// 
 
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 
 
// about supported directives. 
 
//= require bootstrap 
 
//= require jquery 
 
//= require jquery_ujs 
 
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap 
 
//= require turbolinks 
 
//= require dataTables/jquery.dataTables 
 
//= require_tree .
@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,700");/*! 
 
* bootswatch v3.3.6 
 
* Homepage: http://bootswatch.com 
 
* Copyright 2012-2016 Thomas Park 
 
* Licensed under MIT 
 
* Based on Bootstrap 
 
*//*! 
 
* Bootstrap v3.3.6 (http://getbootstrap.com) 
 
* Copyright 2011-2015 Twitter, Inc. 
 
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 
 
@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,700");/*! 
 
/* 
 
* This is a manifest file that'll be compiled into application.css, which will include all the files 
 
* listed below. 
 
* 
 
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 
 
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. 
 
* 
 
* You're free to add application-wide styles to this file and they'll appear at the bottom of the 
 
* compiled file so the styles you add here take precedence over styles defined in any styles 
 
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new 
 
* file per style scope. 
 
*= require dataTables/bootstrap/3/jquery.dataTables.bootstrap 
 
*= require_self 
 
*= require dataTables/jquery.dataTables 
 
*= require_tree . 
 
*/
<div class="table-responsive"> 
 
    <table class="table" id="users" > 
 
    <thead> 
 
    <tr> 
 
     <th>Name</th> 
 
     <th>Email</th> 
 
     <th>Change Type</th> 
 
     <th>Action</th> 
 
     <th>Delete</th> 
 
    </tr> 
 
    </thead> 
 
    <tbody> 
 
     <% @users.each do |user| %> 
 
     <tr> 
 
      <td><%= user.name %></td> 
 
      <td> 
 
      <%= link_to user.email, user %> 
 
      </td> 
 
      <td> 
 
      <%= form_for(user) do |f| %> 
 
       <%= f.select(:role, User.roles.keys.map {|role| [role.titleize,role]}) %> 
 
       <td> 
 
       <button><%= f.submit 'Change Role' %></button> 
 
       </td> 
 
      <% end %> 
 
      </td> 
 
      <td> 
 
      <%= link_to("Delete user", user_path(user), data: { confirm: "Are you sure?" }, method: :delete, class: 'button') unless user == current_user %> 
 
      </td> 
 
     </tr> 
 
     <% end %> 
 
    </tbody> 
 
    </table> 
 
</div> 
 

 
<script> 
 
    $('#users').dataTable(); 
 
</script>

+0

定义“不工作”。 – jonmrich

回答

0

变化的脚本,如:

<script> 
$(document).ready(function() { 
    $('#users').dataTable(); 
}); 
</script> 
相关问题