views:

508

answers:

4

Is there a way to determine what version of Ruby is running from within Rails (either on the web or through script/console)? I have Ruby 1.8.6 installed but I've also installed Ruby Enterprise Edition 1.8.7-20090928 and want to ensure that it's using the right installation.

+3  A: 

Try the constant RUBY_VERSION. I use this extensively to determine whether I'm running under 1.8 or JRuby.

Also, if you're not in production mode, you can do a quick check by hitting the URL "/rails/info/properties"

Mark Westling
+10  A: 

Use the Top-Level Constant

RUBY_VERSION

other useful Top-Level Constants are

RUBY_PATCHLEVEL
RUBY_PLATFORM
RUBY_RELEASE_DATE

here is an irb session:

irb(main):001:0> RUBY_VERSION
=> "1.8.7"
avguchenko
+1  A: 

In addition to the RUBY_VERSION constant and friends you may also want to check out Config::CONFIG. This hash contains not only the version numbers but also a ton of other useful runtime information, like the path to the binary, the hostname, ...

averell
A: 

From the command line

ruby --version
Alister