I am developing several rails projects. Some are still rails 2.3.9, and some are rails3. But using those at the same time, on the same machine can cause some trouble. I use bundles for all my projects, so the gem dependencies are managed. But still, somehow, when running my tests, i get into trouble. If i run
, it complains that it is deprecated. Rubymine doesn't support running tests in my rails 2 project.
The solution? Use gemsets
! Gemsets are a feature from rvm, the Ruby Version Manager. But with gemsets rvm does more than just manage your ruby version!
A gemset is a set of gems, which you can switch at will. So i am using a gemset per project.
Creating a gemset is easy:
rvm gemset create some_name
Using a gemset is equally simple:
rvm gemset use some_name
Showing which gemset is in use:
rvm gemset name
Showing the list of possible gemsets
rvm gemset list
By default, you are using an unnamed gemset, which contains all the gems for your ruby-version. Per project you can create a new gemset. Per gemset you have to re-install your gems, but luckily, using bundler, that is as simple as doing
Now comes the good part:
- Rubymine supports using gemsets, so you can select your gemset to work with, and each time your project is opened, it uses the correct gemset and the correct corresponding scripts (e.g. spec)
- If you place a
.rvmrc file in your project-folder containing
rvm default@projecta, every time you
cd into that folder it will select the default ruby and the projecta gemset. Awesome!