Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 e.g. "Gem::Version('bundler')"

like image 715
ProkopS Avatar asked Aug 01 '14 14:08

ProkopS


People also ask

How do I check my gem version?

To check if a specific version is installed, just add --version , e.g.: gem list -i compass --version 0.12.

Where are gems in a Rails app?

Gems are located in the Gemfile inside your project folder.

How do I install a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.

Is gem installed with Ruby?

The Gem command is included with Ruby 1.9+ now, and is a standard addition to Ruby pre-1.9.


1 Answers

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
like image 192
Erik Avatar answered Oct 07 '22 00:10

Erik