I've gotten a Rails app from someone via heroku to modify. How can I tell, by examining the source code, what version of Rails was used to writ开发者_开发百科e the app?
For Rails 3.x
It should be specified in the GEM file
For Rails 2.x - try the config/environment.rb
The file config/environment.rb may specify it e.g.
\# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION
... but it is not required to.
You can take some educated guesses and try 2.3.2 or 2.3.11. Our own system uses a ton of gems and was pretty happy with 2.3.2 for at least a year.
Which Ruby Version?
A reasonable guess would be 1.8.7 as it has been around for so long. You could also try 1.9.2 but if the app has been around for more than a year, it is unlikely to be using 1.9.x - too many popular gems had problems with 1.9 until this last year or so.
As of Rails 3 it will be in the Gemfile:
gem 'rails', '3.1.0.rc4'
Before Rails 3 it was in config/environment.rb:
RAILS_GEM_VERSION = '2.3.9' unless defined? RAILS_GEM_VERSION
As for the ruby version, there's no way to tell from code. Most rails code will run fine on either Ruby 1.8 or 1.9.
It's listed in the Gemfile
file.
To find out the version of ruby there is a possibility that you can go into the .rvm/log file to see the versions that have been used and the dates they were installed.
精彩评论