环境:Ruby2.0.0,Rails 4.1,Windows8.1,Devise,jquery-datatables rails 1.12.2。我也运行作为租户的行为,这是一个很好的多租户宝石。
除了一个小问题外,我已经启动并运行了数据存储。当从索引操作访问页面时,它不会被格式化和工作。只有浏览器刷新才能启动它,然后它才能工作得很漂亮。由于它在刷新后工作,在我看来,创业板的设置是好的。
我尝试过多次修复。我将页面最小化,以便只显示表。我试过IE和Chrome。无论我是否清除了浏览器缓存和/或重新启动了应用程序,都会发生这种情况。我检查了HTML以确保没有看到任何问题。我检查了服务器日志,发现其中没有任何不同之处。我所做的一切似乎都改变不了什么。
下面是前后视图,显示访问页面的位置,然后刷新页面:
第一次进入:

刷新后,所有操作都正常:

索引操作是基本的,但请注意,它的作用域是以租户身份执行的操作:
def index
@devices = Device.all
@roles = Role.all
endindex.html.erb是:
<div class="row">
<%= render partial: 'index', layout: 'layouts/sf_label', locals: { title: 'List Devices' } %>
</div>部分_index.html.erb是:
<div class="span8">
<table id="datatable">
<thead>
<tr>
<th>Device</th>
<th>Created</th>
<th>Role</th>
</tr>
</thead>
<tbody>
<% @devices.each do |device| %>
<tr>
<td><%= link_to device.name, edit_device_path(device.id) %></td>
<td><%= device.created_at.to_date %></td>
<td><%= device.roles.first.name.titleize unless device.roles.first.nil? %></td>
</tr>
<% end %>
</tbody>
</table>
</div>在Gemfile中:
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
gem 'jquery-ui-rails'在application.js中:
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap在datatable.js.coffee中:
jQuery ->
$('#datatable').dataTable()在devices.js.coffee中:
$('.datatable').dataTable({
"sPaginationType": "bootstrap"
});在application.css.css中:
*= require dataTables/jquery.dataTables
*= require dataTables/jquery.dataTables.bootstrap在日志中,无论哪种方式都是相同的:
Rendered devices/_index.html.erb (253.2ms)
Rendered devices/index.html.erb within layouts/application (254.2ms)
Rendered layouts/_shim.html.erb (1.0ms)
CACHE (0.0ms) SELECT COUNT(*) FROM "roles" INNER JOIN "devices_roles" ON "roles"."id" = "devices_roles"."role_id" WHERE "devices_roles"."device_id" = $1 AND (((roles.name = 'admin') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL))) [["device_id", 51]]
Rendered layouts/_navigation_links.html.erb (3.0ms)
Rendered layouts/_navigation.html.erb (4.0ms)
Rendered layouts/_messages.html.erb (1.0ms)
Completed 200 OK in 290ms (Views: 248.2ms | ActiveRecord: 36.0ms)所有建议都很感激..。
发布于 2014-04-25 06:07:58
试一次:
将turbolinks宝石添加到宝石file>>中
gem 'turbolinks'
gem 'jquery-turbolinks'并将以下内容添加到application.js文件中。
//= require jquery.turbolinks
//= require turbolinks完成捆绑和重新启动服务器。
https://stackoverflow.com/questions/23285111
复制相似问题