Redmine 3.3.0 (Ruby on Rails 4.2.6) Stylesheets Not Generated/Included in Application.CSS

Redmine 3.3.0 (ruby on rails 4.2.6) stylesheets not generated/included in application.css

Apparently my blunder was that I didn't run 'Redmine' at all in development mode. As I understand until now, the ruby on rails asset pipeline wasn't fired up to generate the concatenated application.css. All I had to do was to run the server once in development mode.

rake assets:precompile
rails server -e development

Also found some useful info in this answer: Rails assets not precompiling, css looks different in production and Rails 4: assets not loading in production

This is my first encounter with RoR and I blindly followed an install tutorial for 'Redmine' that didn't include the compile step.

Edit
The issue returned, actually it wasn't even fixed properly. Had to solve some issues with mysql2 adapter and login credentials in order to properly populate the database. After that I tried a lot of things until finally arriving to this steps list:

Added in environments/production.rb

config.serve_static_files = true
config.assets.compile = true
config.assets.precompile = ['*.js', '*.css', '*.css.erb']
config.assets.digest = true
  • Kill the server
  • Clear out tmp/cache/assets
  • Delete public/assets
  • Run rake assets:precompile
  • Start up the server rails s -e production
  • Reloading the page

Run in cmd:

set RAILS_ENV=production
rake generate_secret_token

set RAILS_ENV=production
rake db:migrate

set RAILS_ENV=production
rake redmine:load_default_data

set RAILS_ENV=production
rake tmp:cache:clear

set RAILS_ENV=production
rake assets:precompile

set RAILS_ENV=production
rails server -e development

If I visited the page and opened up web inspector, when I clicked the elink for application.css I still got the empty .css

Eventually I figured out that instead that the gziped version had a size of 1kb which was intriguing. I deleted it and VOILA, it worked. Basically I solved my issue, but I still don't know why the gzip is generated with the empty css.

Redmine 2.0.1 - missing CSS?

It seems that the culprit is... mod_pagespeed. I see the below error when turning on the Firebug:

"NetworkError: 500 Internal Server Error - http://redmine.domain.vn/javascripts/prototype.js,q1338189946.pagespeed.jm.ix8Kb1Gh8H.js"

Disable it and now Redmine is working fine:

<VirtualHost *:80>
ServerName redmine.domain.vn
ServerAdmin quanta@domain.vn
DocumentRoot /var/www/html/redmine/public/
RailsBaseURI /
ErrorLog logs/redmine.error_log

ModPagespeed off

<Directory "/var/www/html/redmine/public/">
Options -MultiViews
Order allow,deny
Allow from all
AllowOverride none
Satisfy Any
</Directory>
</VirtualHost>

Rails 4: assets not loading in production

In /config/environments/production.rb I had to add this:

Rails.application.config.assets.precompile += %w( *.js ^[^_]*.css *.css.erb )

The .js was getting precompiled already, but I added it anyway. The .css and .css.erb apparently don't happen automatically. The ^[^_] excludes partials from being compiled -- it's a regexp.

It's a little frustrating that the docs clearly state that asset pipeline IS enabled by default but doesn't clarify the fact that only applies to javascripts.

Rails assets not precompiling, css looks different in production

In your config/environments/production.rb file, set:

config.serve_static_assets = false (currently it's set to true)

config.assets.compile = true (currently it's set to false)

This should solve your problem.

Let me explain what I am asking you to do.

  • By setting config.serve_static_assets = false, we are telling rails server, don't add ActionDispatch::Static middleware, which is used to serve static assets.

Why not?

That's because in production environment, you are expected to run your application server (like puma) behind a web server (like Apache/Nginx), which is designed to serve static files (including assets) directly, without bothering to send the request to rails application server.

Since, you are not using any web server, we are turning it off.

  • By setting config.assets.compile = true, we are telling rails to compile the requested asset at runtime. i.e. Look for the requested asset in app/assets, vendor/assets, lib/assets and serve it if found from any of these locations.

By default, config.assets.compile is true in development, false in production environment. Since, we are not using web server to serve static assets, we are asking rails to live compile our assets.

For further details refer to the asset pipeline documentation.

Bootstrap won't work in Redmine plugin

Sorry to disappoint, but if you're building a Redmine plugin using Bootstrap, you're doing it wrong. A plugin (no matter for which platform) should offer a seamless user experience with regards to the host platform itself. Since Redmine is not using Bootstrap, there's no reason you should use it for your plugin.

Instead, you should have a look at the app/views directory in Redmine and use the same HTML elements in your plugin. You'll have a more seamless UI and less need for custom CSS... Hope that helps.

How can I change the color of the progress bar of a task in Redmine or where is the code located?

You should actually edit image located at:

your_redmine_root/public/images/task_late.png

Where your_redmine_root is a place where your Redmine is physically installed, and it depends upon underlaying operating system, etc...

So gannt is a combination of html code generated from underlaying RoR application which's view you can edit in app/views/gantts/show.html.erb. Javascript code from public/javascripts/gantt.js and CSS style (theme), which actually might differ if you are using some custom theme or plugin, at default install it's in public/stylesheet/application.css

The particular codes might also be different due to Redmine version, but you are looking for

.task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; }

On Redmine 3.0 it's at line 986. .task_late is ordinary div, and you can set it's css style any way you want...

Don't forget to restart Redmine after editing, and also make sure to refresh your browser's cache.

Pages not rendering properly on Heroku

I hope you don't mind but I took the liberty of going to your site myself to see what the problem is. The issue is that you're configuring to use the asset pipeline but none of your assets are compiled. You can verify this is the case by visiting your main CSS file -- you'll notice there's nothing at all there.

This is likely because you forgot to include compilation directives at the top of your application.css. See the asset pipeline guide for full details, but I bet you're missing a line like this at the top of your application.css:

*= require_self
*= require_tree .

Configuring Rails CSS Caching with Passenger

At the end of your deploy you should be running (as part of the deploy:restart task):

touch tmp/restart.txt

This will let Passenger know it needs to reload the Rails stack for the new code, and the new stylesheets will get cached upon the first request.

What does your current deploy:restart task look like?



Related Topics



Leave a reply



Submit