Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
103ce300
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
103ce300
编写于
5月 18, 2012
作者:
J
Jon Leighton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add changelogs about deprecated stuff [ci skip]
上级
62c6ac2f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
1 deletion
+55
-1
activerecord/CHANGELOG.md
activerecord/CHANGELOG.md
+55
-1
未找到文件。
activerecord/CHANGELOG.md
浏览文件 @
103ce300
## Rails 4.0.0 (unreleased) ##
*
Deprecated most of the 'dynamic finder' methods. All dynamic methods
except for
`find_by_...`
and
`find_by_...!`
are deprecated. Here's
how you can rewrite the code:
* `find_all_by_...` can be rewritten using `where(...)`
* `find_last_by_...` can be rewritten using `where(...).last`
* `scoped_by_...` can be rewritten using `where(...)`
* `find_or_initialize_by_...` can be rewritten using
`where(...).first_or_initialize`
* `find_or_create_by_...` can be rewritten using
`where(...).first_or_create!`
* `find_or_create_by_...!` can be rewritten using
`where(...).first_or_create!`
The implementation of the deprecated dynamic finders has been moved
to the `active_record_deprecated_finders` gem. See below for details.
*Jon Leighton*
*
Deprecated the old-style hash based finder API. This means that
methods which previously accepted "finder options" no longer do. For
example this:
Post.find(:all, :conditions => { :comments_count => 10 }, :limit => 5)
Should be rewritten in the new style which has existed since Rails 3:
Post.where(comments_count: 10).limit(5)
Note that as an interim step, it is possible to rewrite the above as:
Post.scoped(:where => { :comments_count => 10 }, :limit => 5)
This could save you a lot of work if there is a lot of old-style
finder usage in your application.
Calling `Post.scoped(options)` is a shortcut for
`Post.scoped.merge(options)`. `Relation#merge` now accepts a hash of
options, but they must be identical to the names of the equivalent
finder method. These are mostly identical to the old-style finder
option names, except in the following cases:
* `:conditions` becomes `:where`
* `:include` becomes `:includes`
* `:extend` becomes `:extending`
The code to implement the deprecated features has been moved out to
the `active_record_deprecated_finders` gem. This gem is a dependency
of Active Record in Rails 4.0. It will no longer be a dependency
from Rails 4.1, but if your app relies on the deprecated features
then you can add it to your own Gemfile. It will be maintained by
the Rails core team until Rails 5.0 is released.
*Jon Leighton*
*
It's not possible anymore to destroy a model marked as read only.
*Johannes Barre*
*
Added ability to ActiveRecord::Relation#from to accept other ActiveRecord::Relation objects
Record.from(subquery)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录