Engaging Social Software Blog

Icon

Its about engaging.

rvm and rails

This is a summary of the following excellent articles:
RVM: More than Ruby 1.9 and Rails 3
RVM and project-specific gemsets in Rails
Get started right with RVM


Note: Do not use “sudo”

rvmrc

Now there are different kinds of rvmrc files:

System /etc/rvmrc

System wide configuration

User ~/.rvmrc

User wide configuration

Project .rvmrc

Project wide configuration

The most interesting one is the project .rvmrc. Every time you cd, RVM looks for a file called .rvmrc. If it finds it, it executes it.

Global Gemset

Create a globalgemset that contains gems that will be used across multiple projects, then a project-specific gemset for each of our Rails applications. To begin, let’s make our global gemset:

$ rvm gemset create global

$ rvm use @global

Gemset

Ideally you have a Gemset for each project that you are working on. This keeps your system clean, and eliminates “Gem clutter”. Also running bundle installwill use the project defined gemset to also store the gemset .

First, we’ll create another gemset; this one will be specific to our Rails 3 project.

Replacerails3_project with a gemset name that makes more sense for your project:

$ rvm gemset create rails3_project

$ rvm use @rails3_project

Next, create a .rvmrc file at the root of your Rails 3 application. It will look something like this:

rvm 1.9.2@rails3_project

Short cut for the above:

$ rvm –create –rvmrc ruby-version@gemset

This will create the gemset, and the .rvmrc file!

Edit: could not get the above to work, so used this: echo rvm use 1.9.2 > .rvmrc

Note: Do not use “sudo”

This is the key to the magic that’s happening here: RVM is smart enough to know that if it sees a .rvmrc file in a directory, it should load the version specified inside.


Advertisement

Filed under: Web Development, , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.