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.
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Eager-loading association count with Arel (Rails 3
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
相关文章
- Ruby using wrong version of openssl
- Right way to deploy Rails + Puma + Postgres app to
- AWS S3 in rails - how to set the s3_signature_vers
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- How to add a JSON column in MySQL with Rails 5 Mig
- “No explicit conversion of Symbol into String” for
- form_for wrong number of arguments in rails 4
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"
Use
RUBY_VERSION
as mentioned by others.You can then use
Gem::Version
to do version string comparison:Use the Top-Level Constant
other useful Top-Level Constants are
here is an irb session:
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, ...