Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to recompile assets in Rails in case of change. How do I get rid of it?

I have a Rails application. Here is the part of the content of development.rb

config.assets.debug = true
config.assets.compress = false

When I change any js file, I have to call RAILS_ENV=development rake assets:precompile to see the changes. I wonder why? How do I get rid of that? I want just to save javascript file and not to do any extra work.

P.S. It's not only about javascript files. Even when I change a haml file, I also have to call RAILS_ENV=development rake assets:precompile.

like image 785
Alan Coromano Avatar asked Nov 01 '25 13:11

Alan Coromano


2 Answers

Every time you run the assets:precompile Rails place compiled assets into public/assets. The issue is that the assets pipeline will always serve an asset from the public directory if it founds it here. Otherwise it will search assets in the app/assets directory which is the appropriate location for assets in development.

You're not supposed to precompile assets in your development environment, assets precompilation is for production environments. If you want to do it periodically, for example to check compiled/minified assets, don't forget to remove the public/assets directory once you're done.

like image 129
Jef Avatar answered Nov 03 '25 02:11

Jef


Try removing public/assets directory. From your app's directory:

rm -rf public/assets
like image 35
andrunix Avatar answered Nov 03 '25 02:11

andrunix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!