“Consider using bundle exec.”

I came across this error today when trying to run a simple rake routes:

You have already activated rake 0.9.2, but
your Gemfile requires rake 0.8.7. Consider using
bundle exec.

I had no idea what that really meant so I did a little searching and found that it is probably one of the most useful command combinations ever. From http://gembundler.com/man/bundle-exec.1.html:

Execute a command in the context of the bundle

Oh, so then running:

bundle exec rake routes

then produced the desired result. I was wondering if I was going to have to resort to RVM, which seems silly because isn’t the point of Bundler to lock an app’s gem versions rather than having to worry about which RubyGems you’ve installed at your system or user level?

Update: Also related, you may need to run migrations this way too:

bundle exec rake db:migrate