当前位置 : 主页 > 编程语言 > ruby >

ruby-on-rails – 轨道中需要的重要轨道3.2概念4

来源:互联网 收集:自由互联 发布时间:2021-06-23
Ruby on Rails:当我开始使用Rails 4(测试版发布)时,Rails 3中存在哪些概念会被更改或需要完全删除? 还得知道ActiveRecord观察者的用法,它已被提取到一个gem.新宝石将位于github.com,rails-observe
Ruby on Rails:当我开始使用Rails 4(测试版发布)时,Rails 3中存在哪些概念会被更改或需要完全删除?

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

根据发行说明( 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

主要变更和弃用

提取到宝石中的特征:

> Hash-based & Dynamic finder methods
> Mass assignment protection in Active Record models
> ActiveRecord::SessionStore
> Active Record Observers
> Active Resource
> Action Caching
> Page Caching
> Sprockets
> Performance tests

如果使用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!来重写.

网友评论