views:

36

answers:

1

So that if you have a Ruby Version Manager, then you can switch to that mode first before altering the project files. (probably best)

+1  A: 

You can set an .rvmrc file in your project directory, so that you will automatically change to a particular ruby and gemset when you enter the directory. Check out the rvmrc docs for details.

This method doesn't infer versions from the project files, though. If you really wanted to infer Rails version you could put a little script in your .rvmrc file:

RAILS_VERSION=`ruby -e "require 'config/environment'; puts RAILS_GEM_VERSION"`
Dave Pirotte
what if you are using Windows 7 or other platforms but not using RVM?
動靜能量
Ah, thought you were using RVM. Hmm... not sure how you would accomplish this on Windows. It looks like Pik (http://github.com/vertiginous/pik) is supposed to be RVM for Windows, but I don't see anything equivalent to the project-based rvmrc file. I really don't know much at all about Windows scripting, but I'd imagine that you could cobble something together so whenever you enter a directory a script would be executed that would set the current ruby interpreter.
Dave Pirotte