Js.erb asset pipeline power recompiles

My js.erb files are not restored even when the development server restarts. Is there a way to get the asset pipeline to regenerate all javascript attributes every time I restart the server?

If I modify the source .js.erb file, then it is recompiled perfectly, but the code is extracted from the database, reading the sowed data, which may change between server restarts.

+6
source share
2 answers

A late call is here, but having this problem everywhere, and REALLY annoyed by it, dug a little. Here is my solution:

When restarting the rm -rf tmp/cache/* server

This will blow SCSS and other cached assets and force them to recompile.

Instead, you can run rake assets:clean if you want, or use Rake to reboot the server.

Obviously, this slows down the server restart a bit, but it may be worth it to remove this underlying pain point ...

+10
source

Think about any ruby ​​that you run in the asset pipeline, as it happens before your server starts, as this is effectively what happens during production with the asset precompilation stage (and during development it will be updated if the files are changed, since you described). In this case, you will want to reorganize this code into a controller and something in your application / view directory (html.erb / js.erb) so that your code runs on every request.

+1
source

Source: https://habr.com/ru/post/901869/


All Articles