rajat banerjee
rajat banerjee

Reputation: 1294

rails DataTables CSS doesn't get applied in Production mode

I'm using Rails 5 with the jquery-datatables-rails (3.4.0, latest) gem.

CSS on the tables renders fine in development mode. I can walk through the CSS and see it well formed like:

http://localhost:3000/assets/dataTables/jquery.dataTables.self-MD5.css?body=1

However, in Production mode, no styling whatsoever is applied. CSS all gets 'precompiled' or munged into: http://my.ip/assets/application-MD5.css

Chrome can load the remote application-.css file. I verified that a couple of CSS classes appear in both the development mode assets/dataTables/jquery.dataTables..css AND production mode assets/application*.css. Like,

/* line 265, /Users/rb/.rvm/gems/ruby-2.3.1@flv/gems/jquery-datatables-rails-3.4.0/app/assets/stylesheets/dataTables/jquery.dataTables.scss */
table.dataTable,
table.dataTable th,
table.dataTable td {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
}

I found a corresponding 'table.dataTable td' in production application*.css and it looks correct!

But Chrome and Firefox refuse to render them. What am I doing wrong? This is in app/assets/stylesheets/application.css:

*= require_tree .
 *= require dataTables/jquery.dataTables
 *= require jquery-ui
 *= require_self

and this is in production mode's rendered head tag:

<link rel="stylesheet" media="all" href="/assets/application-MD5.css" data-turbolinks-track="reload" />

Upvotes: 2

Views: 295

Answers (1)

rajat banerjee
rajat banerjee

Reputation: 1294

Solution that finally worked:

  1. Create a throw-away new project, rails new fakeProject

  2. Copy all rake assets pipeline settings out of fakeProject/config/environments/production.rb into my projects config/environments/production.rb

  3. push to git, deploy with capistrano

  4. clear cache in chrome, restart puma, see css styling, profit$$$

Unfortunately one of the settings I'd used for rails asset pipeline was killing me. I never figured out which one and just nuked them.

Upvotes: 0

Related Questions