« back to all blogs in Web Design and Development
Keep your assets organized with BlavoSync
Dec 30, 2009When developing new features for existing (or new) Ruby on Rails applications, our UI people like to have some real content to use to optimize the design for an interface that works with the actual data. It’s classic chicken and egg syndrome.
“I cant design that area because I dont know what the content is, but I cant put content there until I know what the design looks like.” - designers everywhere
My solution to this problem has always been to make a dump from the production site and import it locally, then tar up the system directory and pull that down. This works great since I am comfortable with scp and ssh and the mysql command line interface. The ui guys are not comfortable with this, but they do know how to deploy using capistrano, so there are two potential solutions to this particular problem:
- Move into all of my coworkers offices, babysitting their database content and assets and loading these in for my command-line-fearing friends every time they need new data.
- Write a tool that allows my command-line-fearing friends to run a single command to get said assets and db. Something simple and built on existing battle tested tools. Something as simple as cap local:sync.
Obviously #1 doesnt scale, so we’ll hop right on to the second option. Introducing BlavoSync. I’ll not reproduce the README here, but instead will go through basic setup and requirements.
Requirements:
- A reason to have your production stuff on your development machine.
- A production server running mysql and sshd.
- A valid $RAILS_ROOT/config/database.yml file with entries for both production and development.
- The latest capistrano2 and a valid $RAILS_ROOT/config/deploy.rb file with either a :domain or :rsync domain entry.
- The blavosync rubygem, available at http://gemcutter.org (sudo gem install blavosync).
Hopefully you already have a nice little app running somewhere that has some decent data and assets. In your $RAILS_ROOT/config/deploy.rb file add this line to the top:
require “blavosync/recipes”
In addition, ensure that you have an entry either for :domain or :rsync_domain like so:
set :domain, “my.awesomedomain.com”
or if you are using some custom deployment location:
set :rsync_domain, “my.awesomedomain.com”
This covers the basic requirements, on to usage. As long as your $RAILS_ROOT/config/deploy.rb file is working, the only action you need to take is to run the following on your local machine.
cap local:sync
This will dump the production database and load it into your local mysql database, defined in your $RAILS_ROOT/config/database.yml, and then rsync anything in your $RAILS_ROOT/shared/system directory on production into your $RAILS_ROOT/tmp directory in a new system directory. Once this is done, the $RAILS_ROOT/tmp/system directory will be symlinked into $RAILS_ROOT/public/system.
There are some considerations you should take before using this tool, such as do you have enough disk space or bandwidth to pull down all the assets. You may already have a $RAILS_ROOT/public/system directory full of assets, in which case if you want to keep those you should back them up somewhere and delete the system directory, otherwise the symlink may not work.
If you are on OSX you may need to enable FollowSymLinks in your virtualhost entry for these assets to be served by apache.
Leave your thoughts on this
You must register or Log in to post commments
back to top

I’m claiming responsibility for being the biggest whiner referenced above as “designers everywhere.” I am bristling somewhat at the term “command line fearing” however.
@Chris Basnight:
command line is your friend.
@gabekessler: Easy bro… I’ve untangled your mangled svn commits plenty using command line!