Skip to content

Development tips and tricks

maddentim edited this page Jan 16, 2012 · 1 revision

This page contains a few tips and tricks that may help you with development on tracks.

Clearing cached javascript and css files

Rails bundles the various javascript and css files into cached files to improve performance. When changes are made to javascript or css files, you need to force Rails to recreate them. This little script deletes those cached files and then touches the restart.txt file to causes the server (at least if you are running passenger) to restart itself the next time tracks runs. If you are running linux, place the code below in a file called tracks.clear.sh or whatever you prefer. The following steps in a terminal should set it up for you. You may substitute your editor of choice for nano and set your own path for the script (I use ~/myscripts).

mkdir /path/to/myscripts
nano /path/to/myscripts/tracks.clear.sh
# paste in the code
chmod u+x tracks.clear.sh
cd ~/bin
ln -s /path/to/myscripts/tracks.clear.sh tracks.clear

Here is the code for the file itself. Change the /path/to/tracks/ path to the path on your server.

#!/bin/sh

rm /path/to/tracks/public/javascripts/jquery-cached.js
rm /path/to/tracks/public/javascripts/tracks-cached.js
rm /path/to/tracks/public/stylesheets/tracks-cached.css
touch /path/to/tracks/tmp/restart.txt
Clone this wiki locally