RVM Tip When Working on Rails With Multiple Consoles

I’ve been meaning to test out Rails 3 ever since it was finally released. But I didn’t want to deal with the issues of having concurrent versions of Rails 2.3.x and 3 running side by side. The word on the street is that RVM handles them both well.

RVM itself is relative easy to set up. Although, I should note that trying to run the source-head version (from github) on my laptop caused errors… Running the latest rvm tarball did the trick though. (#2 on that list linked)

I installed both Ruby 1.8.7 and 1.9.2 in RVM, and installed the Rails 3 gem on the 1.9.2 install. Everything went smoothly here.

Now to sidestep for just a second: I like to have multiple terminal tabs running when developing in Rails. One just runs the local dev server, one will run autospec (or the Rails console), and another [one or two] is the utility one for running various shell commands.

So I was in a second terminal tab and wanted to just create a new scaffold with:
> rails generate scaffold User name:string email:string
This generated a brand new rails app in a new folder called ‘generate’. What gives? I double and triple checked my syntax to make sure it was correct. It was. I stopped the web server in the other tab and ran the same command there. Bingo, worked like a charm. Argh!

Finally the light turned on. You need to run RVM in each tab/window. Since RVM is a virtual environment, that state doesn’t persist in different sessions.
> rvm use 1.9.2
> rails generate scaffold User name:string email:string
Makes sense once you realize what’s going on, but was rather frustrating before that point was reached.

Copyright © 2017 - Scott Williams - Powered by Octopress