Rod McLaughlin


Precompile your assets, like your grandma told you (23 jan 13)

You changed your CSS. You got rid of <center>. It looks good on your development machine. You deploy the whole of the app/ folder into production, and 

$ touch tmp/restart.txt # If you are using the very easy-to-use Passenger app

You look at the production website, and it looks even worse than it did before. You google "Why the $#$% doesn't my CSS work in production?".

Wading through acres of waffle on stackoverflow.com, you eventually find out you have to PRECOMPILE your ASSETS. Well, of course! You wouldn't expect Ruby on Rails to work that out for you. Instead of just touching restart.txt, I wrote a little script to help me restart my app every time I redeploy it:

startup.sh:

#!/bin/sh
rake assets:precompile
touch tmp/restart.txt

$ chmod 754 startup.sh
$ ./startup.sh

 

and we're off.

 



Back
Portland London