Determine ruby version from within Rails

Daniel Vandersluis picture Daniel Vandersluis · Oct 19, 2009 · Viewed 38k times · Source

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.

Answer

trondozer picture trondozer · Oct 19, 2009

Use this global constant:

RUBY_VERSION

Other relevant global constants include:

RUBY_PATCHLEVEL
RUBY_PLATFORM
RUBY_RELEASE_DATE

Usage example via irb session:

irb(main):001:0> RUBY_VERSION
=> "1.8.7"