What is the purpose of the RAILS_GEM_VERSION
setting in config/environment.rb
? Is it supposed to stop your app from running under an unexpected version of Rails?
config / environment.rb中RAILS_GEM_VERSION设置的目的是什么?是否应该阻止您的应用程序在意外版本的Rails下运行?
I just keep Rails updated to the latest release on my laptop and in production. Since I do that, can I comment out RAILS_GEM_VERSION
or should I set it for some reason?
我只是将Rails更新到我的笔记本电脑和生产中的最新版本。既然我这样做了,我可以注释掉RAILS_GEM_VERSION或者我应该出于某种原因设置它吗?
1 个解决方案
#1
Since you can have more than one version of Rails installed on your system (you can check with gem list rails), your application needs to know which version it is supposed to use. It won't be very clever just to "keep Rails updated to the latest release" and let the application use the newest version, since since new version of Rails could very easily break it (every new release means some changes to the API). This constant is irrelevant, however, if you "freeze" the version of Rails your app is build for, in the vendor folder. Btw. freezing Rails is a good practice, since your app is then more independent on the environment.
由于您的系统上可以安装多个版本的Rails(您可以查看gem list rails),因此您的应用程序需要知道它应该使用哪个版本。仅仅将“保持Rails更新到最新版本”并让应用程序使用最新版本并不是非常聪明,因为新版本的Rails很容易破解它(每个新版本都意味着对API的一些更改)。但是,如果您在供应商文件夹中“冻结”应用程序构建的Rails版本,则此常量无关紧要。顺便说一句。冻结Rails是一种很好的做法,因为您的应用程序更加独立于环境。
#1
Since you can have more than one version of Rails installed on your system (you can check with gem list rails), your application needs to know which version it is supposed to use. It won't be very clever just to "keep Rails updated to the latest release" and let the application use the newest version, since since new version of Rails could very easily break it (every new release means some changes to the API). This constant is irrelevant, however, if you "freeze" the version of Rails your app is build for, in the vendor folder. Btw. freezing Rails is a good practice, since your app is then more independent on the environment.
由于您的系统上可以安装多个版本的Rails(您可以查看gem list rails),因此您的应用程序需要知道它应该使用哪个版本。仅仅将“保持Rails更新到最新版本”并让应用程序使用最新版本并不是非常聪明,因为新版本的Rails很容易破解它(每个新版本都意味着对API的一些更改)。但是,如果您在供应商文件夹中“冻结”应用程序构建的Rails版本,则此常量无关紧要。顺便说一句。冻结Rails是一种很好的做法,因为您的应用程序更加独立于环境。