轨道中需要的重要轨道3.2概念4

Roc*_*ing 3 ruby-on-rails ruby-on-rails-3

Ruby on Rails:当我开始使用Rails 4(测试版发布)时,Rails 3中存在哪些概念会被更改或需要完全删除?

还得知道ActiveRecord观察者的用法,它已被提取到一个gem.新宝石将位于github.com,rails-observers.

Ben*_*van 5

根据发行说明(http://edgeguides.rubyonrails.org/4_0_release_notes.html):

强调

Ruby 2.0首选; 需要1.9.3+

这是非常明显的.

强参数

允许您为控制器的质量分配指定允许的属性.

在这里阅读更多相关信息:http://blog.remarkablelabs.com/2012/12/strong-parameters-rails-4-countdown-to-2013

Turbolinks

"不是让浏览器在每次页面更改之间重新编译JavaScript和CSS,而是让当前页面实例保持活动状态,只替换头部中的正文和标题."

请参阅github页面:https://github.com/rails/turbolinks

俄罗斯娃娃缓存

这是一种缓存技术,您可以在这里阅读更多信息:http://blog.remarkablelabs.com/2012/12/russian-doll-caching-cache-digests-rails-4-countdown-to-2013

主要变更和弃用

提取到宝石中的特征:

如果使用Rails默认测试框架,则目录的更改如下:

  • 测试/单位 - >测试/模型
  • 测试/单位/助手 - >测试/助手
  • 测试/功能 - >测试/控制器
  • 测试/功能 - >测试/邮件
  • 测试/集成 - >测试/验收

供应商插件

已过时.您在vendor/plugins中可能拥有的任何插件都必须作为gem安装.

积极记录

不推荐使用以下方法,需要重写如下:

  • find_all_by_...可以使用重写where(...).
  • find_last_by_...可以使用重写where(...).last.
  • scoped_by_...可以使用重写where(...).
  • find_or_initialize_by_...可以使用重写where(...).first_or_initialize.
  • find_or_create_by_...可以使用find_or_create_by(...)或重写where(...).first_or_create.
  • find_or_create_by_...!可以使用find_or_create_by!(...)或重写where(...).first_or_create!.