Snowman
Snowman

Reputation: 32061

rake assets:precompile every time I edit CSS?

When I looked at the HTML source for my main page, the CSS that Rails was linking to was in /stylesheets/application.css. When I tried to click that link, I would get a 404 not found error from Passenger (Apache).

So what ended up working was setting config.assets.compile = true in my config file and running rake assets:precompile. This then changed the CSS link to something like /assets/application-5310fa2adccd74453c084cf221eaeeef.css, and this was something I could click on and could be found.

So now what I'm doing is every time I edit my CSS file, I run precompile. Is this the correct way to do things? Do I really have to call this every time I edit my CSS file? Is this the purpose of precompiling, to make sure my assets are able to be served by Apache?

Upvotes: 1

Views: 1920

Answers (1)

Aman Garg
Aman Garg

Reputation: 4218

When you are running your application in production mode, it is advised to precompile the static assets to enhance the performance.

But if you want to skip it, you can use

In config/environmets/production.rb

config.assets.compile = true

After this, you don't need to precompile assets after any change in css but it can slow down the performance and speed of your page load.

Upvotes: 4

Related Questions