简体   繁体   中英

Rails how to get gem version in app

Do you know how to show in my application the version of gem? I don't need a rake task, I want to show the version in admin page.

Like eg "Gem::Version('bundler')"

You would use the following:

bundler_version = Gem.loaded_specs['bundler'].version
#=> Gem::Version.new("1.6.2")

The Gem::Version's string representation is just the version number.

puts bundler_version
# 1.6.2

I have another one:

Gemname::VERSION::STRING

Example:

puts Rails::VERSION:STRING
#4.1.1
gem -v

or

--version

or you can simply in command prompt write gem -help and it will show you how

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM