简体   繁体   中英

Ruby on Rails 2.3.8: How do I require a specifc version of a gem?

currently, I have

 config.gem 'gem_name', :version => "0.1" 

but, i think that means at least this version.

How do I specify: exactly this version?

I guess this isn't really an answer but the code you have written is for the exact version. If it was for 'at least this version' it would look like:

config.gem 'gem_name', :version => ">=0.1" 

And if you wanted to specify a range that your version would fall into, it would be:

config.gem 'gem_name', :version => ['>= 0.1', '< 1.1']

I would use Bundler with Rails: http://gembundler.com/rails23.html

If you go the Bundler route, you can specify your exact version in your Gemfile .

If you decide not to use Bundler, you can also specify the gem version before you require the gem, instead of doing config.gem ... :

require 'rubygems'
gem 'gem_name', "= 0.1"
require 'gem_name'

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