[英]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 我将Bundler与Rails结合使用: http : //gembundler.com/rails23.html
If you go the Bundler route, you can specify your exact version in your Gemfile
. 如果您走Bundler路线,则可以在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 ...
: 如果您决定不使用Bundler,也可以在需要gem之前指定gem版本,而不是执行config.gem ...
:
require 'rubygems'
gem 'gem_name', "= 0.1"
require 'gem_name'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.