ruby on rails – bundle reinstall

After an OS upgrade I needed to reinstall all the gems for my Rails project (well, I probably didn’t need to do it, but it seemed the quickest way).

Since I used RVM and only had one Ruby on Rails project I was working on, doing so is easy, though not intuitive.

To uninstall all the gems:

$ rvm gemset empty

Then install them the regular way:

$ bundle install 

You might get an error that looks like this: “There was an error in your Gemfile, and Bundler cannot continue.”.  If that’s the case, run:

$ gem install bundler

Ruby on Rails unit test: cannot find table error

If your Ruby on Rails unit tests complain about not being able to find a table after you’ve added a new model, it just means you forgot to prepare the test database with the latest data.  The error looks like this:

ActiveRecord::StatementInvalid: Could not find table ‘yourtablenamehere’

To fix, just run:

rake db:test:prepare

and then re-run your test.