Error in rake db:migrate: rake aborted! uninitialized constant Rake::DSL

I’ve never had this issue before, but I recently started using rvm and for whatever reason got the following error when trying to do rake db:migrate

rake aborted!
uninitialized constant Rake::DSL
/usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2482:in `const_missing’

After googling around and trying a bunch of convoluted solutions (many which addressed a broken 0.9.0 build of rake), I found that adding the following line to my Rakefile fixed everything:

require ‘rake/dsl_definition’

Get Familiar with Ruby using EdgeCase’s Ruby Koans

EdgeCase has published a great walkthrough of the various Ruby language features. They call it Ruby Koans.  The Ruby Koans are a a collection of broken tests.  Each broken test is designed to teach you something about the Ruby language.  Many are fill-in-the-blank, eg:

  def test_every_object_has_different_id
    obj = Object.new
    another_obj = Object.new
    assert_equal __, obj.object_id != another_obj.object_id
  end

To pass this koan/test, you’d replace the “__” with true, because new instances of objects have new object_ids.

I wouldn’t recommend this for people new to programming, but if you’re like me and used Ruby a few years ago but have fallen out of practice, it’s a perfect re-introduction.  If you’re new to Ruby but have a solid background in other languages, this may be of use as well.