加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 01:25:55 所属栏目:百科 来源:网络整理
导读:Ruby on Rails:当我开始使用Rails 4(测试版发布)时,Rails 3中存在哪些概念会被更改或需要完全删除? 还得知道ActiveRecord观察者的用法,它已被提取到一个gem.新宝石将位于github.com,rails-observers. 解决方法 根据发行说明( http://edgeguides.rubyonrail
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!来重写.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读