I will show you my problem with two screenshots.
Here you can see the empty table in good shape: empty table
When I fill it up with data DataTables doen't do any effect to the appearance anymore. full table
All tables on other pages have the same problem.
Many thanks to everyone who tries to solve the issue!
Here is my Code: Gemfile:
source 'https://rubygems.org'
gem 'rails', '5.1.2'
gem 'bcrypt', '3.1.11'
gem 'faker', '1.7.3'
gem 'carrierwave', '1.1.0'
gem 'mini_magick', '4.7.0'
gem 'fog', '1.40.0'
gem 'will_paginate', '3.1.5'
gem 'bootstrap-will_paginate', '1.0.0'
gem 'bootstrap-sass', '3.3.7'
gem 'puma', '3.9.1'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks', '5.0.1'
gem 'jbuilder', '2.7.0'
group :development, :test do
gem 'sqlite3', '1.3.13'
gem 'byebug', '9.0.6', platform: :mri
end
group :development do
gem 'web-console', '3.5.1'
gem 'listen', '3.0.8'
gem 'spring', '2.0.2'
gem 'spring-watcher-listen', '2.0.1'
end
group :test do
gem 'rails-controller-testing', '1.0.2'
gem 'minitest-reporters', '1.1.14'
gem 'guard', '2.14.1'
gem 'guard-minitest', '2.4.6'
end
group :production do
# gem 'pg', '0.20.0'
# gem 'sqlite3', '1.3.13'
end
# for jquery-datatables-rails
gem 'jquery-ui-rails'
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
gem 'jquery-turbolinks'
# for best_in_place
gem 'best_in_place'
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Application.js:
// 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, 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. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
// require jquery
// require jquery_ujs
// require bootstrap
// keine Ahnung, ob rails-ujs auch benötigt wird??
// require rails-ujs
// require turbolinks
// require_tree .
//
//= require jquery
//= require jquery.turbolinks
//= require best_in_place
//= require jquery_ujs
//= require dataTables/jquery.dataTables
//= require bootstrap
//= require turbolinks
//= require_tree .
Application.css:
/*
* 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, 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 other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*= require jquery-ui/core
*= require dataTables/src/demo_table_jui
*/
Coffee Script:
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
jQuery ->
$('#preferences').dataTable
sPaginationType: "full_numbers"
bJQueryUI: true
jQuery ->
$('.best_in_place').best_in_place()
The View to the page:
<% if logged_in? %>
<div class="center jumbotron">
<p id="notice"><%= notice %></p>
<h1>Präferenzen bearbeiten</h1>
<table id="preferences" class="display">
<thead>
<tr>
<th>Institut</th>
<th>Präferenzwert</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% @current_user.preferences.each do |preference| %>
<tr>
<td><%= (Institute.find_by(id: preference.institute_id)).name %></td>
<td><%= preference.preference_value %></td>
<td><%= link_to 'Bearbeiten', edit_preference_path(preference) %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%if @current_user.preferences.empty? %>
<%= button_to "Präferenzen erstellen", class: "btn btn-primary", :controller => 'preferences', :action => 'create_all'%>
<%end%>
</div>
<% end %>
Edit: Maybe these log files can help to solve the issue, first I upload the logfile when I get the empty preference table:
Started GET "/preferences" for 127.0.0.1 at 2018-02-22 12:06:33 +0100
Processing by PreferencesController#index as HTML
Rendering preferences/index.html.erb within layouts/application
[1m[36mUser Load (0.3ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 2], ["LIMIT", 1]]
[1m[36mPreference Load (0.3ms)[0m [1m[34mSELECT "preferences".* FROM "preferences" WHERE "preferences"."user_id" = ?[0m [["user_id", 2]]
Rendered preferences/index.html.erb within layouts/application (49.2ms)
Rendered layouts/_rails_default.html.erb (215.1ms)
Rendered layouts/_shim.html.erb (0.4ms)
Rendered layouts/_header.html.erb (1.9ms)
Rendered layouts/_footer.html.erb (0.6ms)
Completed 200 OK in 300ms (Views: 293.2ms | ActiveRecord: 2.8ms)
And here ist the upload of the data-filled preference table:
Rendering preferences/index.html.erb within layouts/application
[1m[36mPreference Load (0.3ms)[0m [1m[34mSELECT "preferences".* FROM "preferences" WHERE "preferences"."user_id" = ?[0m [["user_id", 2]]
[1m[36mInstitute Load (0.6ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 1], ["LIMIT", 1]]
[1m[36mInstitute Load (0.7ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 2], ["LIMIT", 1]]
[1m[36mInstitute Load (0.3ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 3], ["LIMIT", 1]]
[1m[36mInstitute Load (0.2ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 4], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 5], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 6], ["LIMIT", 1]]
[1m[36mInstitute Load (0.2ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 7], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 8], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 9], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 10], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 11], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 12], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 13], ["LIMIT", 1]]
[1m[36mInstitute Load (5.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 14], ["LIMIT", 1]]
[1m[36mInstitute Load (0.7ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 15], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 16], ["LIMIT", 1]]
[1m[36mInstitute Load (0.2ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 17], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 18], ["LIMIT", 1]]
[1m[36mInstitute Load (0.2ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 19], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 20], ["LIMIT", 1]]
[1m[36mInstitute Load (0.2ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 21], ["LIMIT", 1]]
Rendered preferences/index.html.erb within layouts/application (112.7ms)
Rendered layouts/_rails_default.html.erb (375.9ms)
Rendered layouts/_shim.html.erb (1.3ms)
Rendered layouts/_header.html.erb (4.9ms)
Rendered layouts/_footer.html.erb (3.2ms)
Completed 200 OK in 1398ms (Views: 515.5ms | ActiveRecord: 425.1ms)