So that if you have a Ruby Version Manager, then you can switch to that mode first before altering the project files. (probably best)
views:
36answers:
1
+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
2010-09-05 17:15:00
what if you are using Windows 7 or other platforms but not using RVM?
動靜能量
2010-09-05 19:08:14
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
2010-09-06 00:06:04