Anthony Myers
Anthony Myers

Reputation: 401

Specifically stating the Ruby version in my Rails project (RVM)

I'm a little confused on using Ruby Version Manager. I was just wondering how to handle ruby updates for my web apps.

For example, I start a new Rails project and I tell RVM to use a specific version of Ruby like so: rvm use ruby-2.0.0@my-project-name --create

Then say months down the road a new version of Ruby is released. What do I do then? Do I go back in and tell RVM to use the newer version? I want to build something that is always using the latest version of Ruby.

I'm assuming people build Rails apps, but don't always update to the newest version of Ruby and Rails?

Thanks, just starting out with all this, and trying to wrap my head around it.

Upvotes: 0

Views: 70

Answers (1)

neydroid
neydroid

Reputation: 1951

There are three parts in this, Ruby, Gems and Rails Project, RVM can help organize everything in this order Ruby Interpreter/Version -> Gemset -> Rails Project

First Ruby:

You can use rvm list known to list all Ruby versions available in MRI, Rubinius, JRuby and others, after that you can install any version and interpreter like:

  • If you use MRI then rvm install 2.1 will install the latest in the 2.1 branch (2.1.1 being the latest).
  • For Rubinius rvm install rbx will install the latest stable Rubinius.
  • For JRuby rvm install jruby will install the latest stable JRuby.

After installing the version you're going to use, you need to specify that you're going to use it, like this for Rubinius: rvm rbx.

Second Gemset:

RVM gives you the ability to define different gemsets in each installed Ruby version that allows you to install gems for a specific project. For this Rubinius version I can:

  • Create a gemset like rvm gemset create latestRails.
  • Use a gemset rvm rbx@latestRails.
  • Show current Ruby/gemset rvm current.
  • Install latest Rails version in this gemset gem install rails.

Third Rails:

To keep Rails updated, you can use Bundler with a command like bundle update to keep all the gems updated (this are updated inside the current Ruby/gemset and the Gemfile) or a list/single gem of the project, for more info see "Bundle Update Documentation".

I hope I could help you.

Upvotes: 1

Related Questions