升级前环境:
- Ruby版本:1.9.3
- Rails版本:3.1.1
升级后环境:
- Ruby版本:2.0.0p598
- Rails版本:3.2.2
项目文件结构变更
将项目从Rails3.1.1升级到Rails3.2.2之后,报出了插件即将被废除的警告,因为在Rails4中将会把第三方插件从vendor下移除。
Rails Guide中关于这两个版本的vendor文件夹描述如下:
vendor
Rails3.2: A place for all third-party code. In a typical Rails application, this includes Ruby Gems, the Rails source code (if you optionally install it into your project) and plugins containing additional prepackaged functionality.
Rails4: A place for all third-party code. In a typical Rails application, this includes Ruby Gems and the Rails source code (if you optionally install it into your project).
升级方案:
Rails 3.2 deprecates vendor/plugins and Rails 4.0 will remove them completely. While it’s not strictly necessary as part of a Rails 3.2 upgrade, you can start replacing any plugins by extracting them to gems and adding them to your Gemfile. If you choose not to make them gems, you can move them into, say, lib/my_plugin/* and add an appropriate initializer in config/initializers/my_plugin.rb.
方法的变更
#方法被淘汰,使用attr_accessor+在类被实例化时赋值的方式替代
attr_accessor_with_default
#方法被淘汰,使用class_attribute替代
class_inheritable_accessor
#route对象的获取方式变更
route.path #Rails3.1
route.path.spec.to_s #Rails3.2
#String转ActiveSupport::SafeBuffer的方法
"lissdy".html_safe
其他警告
syck has been removed, psych is used instead
这条警告是当前版本的delayed_job使用了已经废除的yml文件加载方式导致的(同时delayed_job不可用),升级delayed_job版本即可。