我的 Rails 应用程序如何接受 RAILS_GEM_VERSION 次要版本更新
我的 Rails 项目在 /config/environment.rb 中有这一行
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
由于我们现在有 2.3.5 作为最新升级,有没有办法让我的environment.rb 接受次要版本更新?
(无需我明确将 2.3.2 更改为 2.3.5)
My rails project has this line in /config/environment.rb
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
As we now have 2.3.5 as the most recent upgrade, is there a way to make my environment.rb accept minor version bumps?
(without I have to explicitly change 2.3.2 to 2.3.5)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,没有。
您的应用程序需要使用特定的 Rails 版本,主要是因为不同的小版本可能需要额外的步骤来升级框架,例如更改 boot.rb。
No, there isn't.
You application needs to use a specific Rails version mostly because different tiny releases might require additional steps to upgrade the framework such as changes to boot.rb.
自 Rails 2 以来,事情已经发生了一些变化,所以我今天将分享从 5.0.0 到 5.0.0.1 所必须做的事情。
我的
Gemfile
读取了gem 'rails', '~>; 5.0.0'
。我认为这已经足够了,但是捆绑安装 没有更新任何新内容。所以我尝试用 gem 'rails', '~>; 来强制它。 5.0'
当我运行更新时也没有做任何新的事情(注意:这是我自己的实验性应用程序,而不是我正在开发的其他人的应用程序 - 不要只是默认允许次要版本更新来解决像这样的问题;))。所以我不得不尝试其他一些方法来强制执行此安全补丁/修补程序。首先,我必须在本地安装软件包:
gem install Rails --version 5.0.0.1
接下来,我更新了捆绑程序:
bundle install
...我在输出:
使用rails 5.0.0.1 (was 5.0.0)
当我运行
./bin/rakerails:update
时,它擦除了我的config/的内容paths.rb 文件更改了我在各种配置文件中的许多设置(其中一些是需要更改的危险安全设置),以及其他一些看似良性的更改。虽然这是预期的行为,但我指出这并不是更新 Rails 次要补丁/修补程序的理想方法。
Things have evolved a bit since Rails 2, so Ill share what I had to do to get from 5.0.0 to 5.0.0.1 today.
My
Gemfile
readgem 'rails', '~> 5.0.0'
. I figured that was enough, butbundle install
was not updating anything new. So I tried to force it withgem 'rails', '~> 5.0'
which also did nothing new when I ran update (note: this is for an experimental app of my own, and not someone else's app I am working on - don't just default to allowing minor version updates to solve problems like this ;) ). So I had to try a few other ways to force this security patch/hotfix.First, I had to install the package locally:
gem install rails --version 5.0.0.1
Next, I updated bundler:
bundle install
...and I saw this in the output:
Using rails 5.0.0.1 (was 5.0.0)
When I ran
./bin/rake rails:update
, it wiped the contents of myconfig/routes.rb
file, changed many of my settings in various config files (some of which were dangerous security settings to change), among a few other seemingly benign changes. While this is the expected behavior, I am pointing this out as not exactly a desirable method for updating a minor patch/hotfix for rails.首先,您需要将版本从2.3.5更改为2.3.5,然后运行
Firstly, you need to change the version to 2.3.5 from 2.3.5 and then run