Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling asset bundling in production, Rails 3.1?

I have an existing Rails application I am upgrading to Rails 3.1 from Rails 3.0. All is going well in development, but when moving to production my stylesheets are breaking, apparently due to asset compilation.

I would like to disable asset compilation in production until I can get the stylesheet conflicts worked out, but the config switches I throw at it dont seem to be working.

production.rb

# Don't fallback to assets pipeline
config.assets.compile = false

# Do not compress assets
config.assets.compress = false

# Generate digests for assets URLs
config.assets.digest = false

After restarting Passenger application.css is the only stylesheet being served, contains inline content. In the development environment I have:

development.rb

# Do not compress assets
config.assets.compress = false

# Expands the lines which load the assets
config.assets.debug = true

...which leads to several stylesheets being loaded, not just application.css, and working styles in the application.

application.rb

=stylesheet_link_tag 'application'
=javascript_include_tag 'application'

application.css

*= require flutie
*= require_self
*= require jquery-ui-1.8.14.custom.css
*= require demo_table

All assets are setup in app/assets

like image 401
Allyl Isocyanate Avatar asked Sep 16 '11 22:09

Allyl Isocyanate


People also ask

How do you Precompile rails assets?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

What does rake assets Clean do?

Two cleanup tasks: rake assets:clean is now a safe cleanup that only removes older assets that are no longer used, while rake assets:clobber nukes the entire public/assets directory. The clean task allows for rolling deploys that may still be linking to an old asset while the new assets are being built.

What is Require_self?

//= require_self. It loads the file itself, to define the order that the files are loaded.


1 Answers

In your application.rb you need to disable it. If you want it to be like this in production only leave it as true in your application.rb and just put the config.assets.enabled = false in your production.rb

# Enable the asset pipeline
config.assets.enabled = false
like image 149
Nick Avatar answered Sep 21 '22 13:09

Nick