Rails3.1.1到Rails3.2.2升级笔记

升级前环境:

  • 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版本即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值