Welcome back!

Please use the form below to sign in.


919.790.9800

The company. The team.

« back to all blogs in Web Design and Development

Keep your assets organized with BlavoSync

Dec 30, 2009

When 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:

  1. 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.
  2. 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:

  1. A reason to have your production stuff on your development machine.
  2. A production server running mysql and sshd.
  3. A valid $RAILS_ROOT/config/database.yml file with entries for both production and development.
  4. The latest capistrano2 and a valid $RAILS_ROOT/config/deploy.rb file with either a :domain or :rsync domain entry.
  5. 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

Keep your assets organized  with BlavoSync
Chris Basnight said on December 30th, 2009 @ 11:50am

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.


Keep your assets organized  with BlavoSync
gabekessler said on December 30th, 2009 @ 1:15pm

@Chris Basnight:
command line is your friend.


Keep your assets organized  with BlavoSync
Chris Basnight said on December 30th, 2009 @ 5:57pm

@gabekessler: Easy bro… I’ve untangled your mangled svn commits plenty using command line!


You must register or to post commments

back to top

Great Partners

Basecamp

We write too...

see more