Skip to content

Commit 47e7db8

Browse files
committed
Update 4.2 release notes (zh-CN).
1 parent 971ce64 commit 47e7db8

File tree

1 file changed

+66
-26
lines changed

1 file changed

+66
-26
lines changed

source/zh-CN/4_2_release_notes.md

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Ruby on Rails 4.2 发布记
33

44
Rails 4.2 精华摘要:
55

6-
本篇仅记录主要的变化。要了解关于已修复的 Bug、功能变更等,请参考 [Rails GitHub 主页](https://github.com/rails/rails)上各个 Gem 的 CHANGELOG 或是 [Rails 的提交历史](https://github.com/rails/rails/commits/master)
6+
本篇仅记录主要的变化。要了解关于已修复的 Bug、特性变更等,请参考 [Rails GitHub 主页](https://github.com/rails/rails)上各个 Gem 的 CHANGELOG 或是 [Rails 的提交历史](https://github.com/rails/rails/commits/master)
77

88
--------------------------------------------------------------------------------
99

@@ -12,8 +12,8 @@ Rails 4.2 精华摘要:
1212

1313
如果您正试着升级现有的应用程序,最好有广的测试覆盖度。首先应先升级至 4.1,确保应用程序仍正常工作,接着再升上 4.2。升级需要注意的事项在 [Ruby on Rails 升级指南](upgrading_ruby_on_rails.html#upgrading-from-rails-4-1-to-rails-4-2)可以找到。
1414

15-
重要新功能
16-
--------------
15+
重要新特性
16+
---------
1717

1818
### 外键支援
1919

@@ -42,9 +42,14 @@ Railties
4242

4343
### 移除
4444

45-
* 移除了 `rails application` 命令。
45+
* 移除 `rails application` 命令。
4646
([Pull Request](https://github.com/rails/rails/pull/11616))
4747

48+
### 弃用
49+
50+
* 弃用 `Rails::Rack::LogTailer`,没有替代方案。
51+
([Commit](https://github.com/rails/rails/commit/84a13e019e93efaa8994b3f8303d635a7702dbce))
52+
4853
### 值得一提的变化
4954

5055
* 导入 `bin/setup` 脚本来启动应用程序。
@@ -53,7 +58,7 @@ Railties
5358
* `config.assets.digest` 在开发模式的缺省值改为 `true`
5459
([Pull Request](https://github.com/rails/rails/pull/15155))
5560

56-
* 导入给 `rake notes` 注册新扩展功能的 API。
61+
* 导入给 `rake notes` 注册新扩展特性的 API。
5762
([Pull Request](https://github.com/rails/rails/pull/14379))
5863

5964
* 导入 `Rails.gem_version` 作为返回 `Gem::Version.new(Rails.version)` 的便捷方法。
@@ -66,7 +71,7 @@ Action Pack
6671

6772
### 弃用
6873

69-
* 弃用路由的 `:to` 选项里,`:to` 可以指向符号或不含井号的字串这两个功能
74+
* 弃用路由的 `:to` 选项里,`:to` 可以指向符号或不含井号的字串这两个特性
7075

7176
```ruby
7277
get '/posts', to: MyRackApp => (No change necessary)
@@ -79,6 +84,13 @@ Action Pack
7984

8085
### 值得一提的变化
8186

87+
* `render nothing: true` 或渲染 `nil` 主体不再给响应加一个空白。
88+
([Pull Request](https://github.com/rails/rails/pull/14883))
89+
90+
* 导入 `always_permitted_parameters` 选项,用来设定全局允许赋值的参数。默认值是
91+
`['controller', 'action']`
92+
([Pull Request](https://github.com/rails/rails/pull/15933))
93+
8294
* `*_filter` 方法已经从文档中移除,已经不鼓励使用。偏好使用 `*_action` 方法:
8395

8496
```ruby
@@ -105,7 +117,7 @@ Action Pack
105117
*RFC-4791 新增 HTTP 方法 `MKCALENDAR`
106118
([Pull Request](https://github.com/rails/rails/pull/15121))
107119

108-
* `*_fragment.action_controller` 通知消息的 Payload 现在包含 Controller 与动作名称
120+
* `*_fragment.action_controller` 通知消息的 Payload 现在包含控制器与动作名称
109121
([Pull Request](https://github.com/rails/rails/pull/14137))
110122

111123
* 传入 URL 辅助方法的片段现在会自动 Escaped
@@ -118,7 +130,7 @@ Action Pack
118130
([Pull Request](https://github.com/rails/rails/pull/14280))
119131

120132
Action View
121-
-------------
133+
-----------
122134

123135
请参考 [CHANGELOG][action-view] 来了解更多细节。
124136

@@ -134,36 +146,49 @@ Action View
134146

135147
### 值得一提的变化
136148

149+
* 表单帮助方法针对隐藏栏位不再加上含有行内样式的 `<div>`
150+
([Pull Request](https://github.com/rails/rails/pull/14738))
151+
137152
Action Mailer
138153
-------------
139154

140155
请参考 [CHANGELOG][action-mailer] 来了解更多细节。
141156

142157
### 值得一提的变化
143158

159+
* 添加 `show_previews` 设定选项,用来在开发环境以外启用 Mailer 预览。
160+
([Pull Request](https://github.com/rails/rails/pull/15970))
161+
144162
Active Record
145163
-------------
146164

147165
请参考 [CHANGELOG][active-record] 来了解更多细节。
148166

149167
### 移除
150168

169+
* 移除 `cache_attributes` 以及其它相关的方法,所有的属性现在都会缓存了。
170+
([Pull Request](https://github.com/rails/rails/pull/15429))
171+
151172
* 移除已弃用的方法 `ActiveRecord::Base.quoted_locking_column`.
152173
([Pull Request](https://github.com/rails/rails/pull/15612))
153174

154175
* 移除已弃用的方法 `ActiveRecord::Migrator.proper_table_name`
155176
请改用 `ActiveRecord::Migration` 的实例方法:`proper_table_name`
156177
([Pull Request](https://github.com/rails/rails/pull/15512))
157178

158-
* 移除 `cache_attributes` 以及其它相关的方法,所有的属性现在都会快取了。
159-
([Pull Request](https://github.com/rails/rails/pull/15429))
160-
161179
* 移除了未使用的 `:timestamp` 类型。把所有 `timestamp` 类型都改为 `:datetime` 的别名。
162180
修正在 `ActiveRecord` 之外,栏位类型不一致的问题,譬如 XML 序列化。
163181
([Pull Request](https://github.com/rails/rails/pull/15184))
164182

165183
### 弃用
166184

185+
* 弃用对 `has_many :through` 自动侦测 counter cache 的支持。要自己对 `has_many`
186+
`belongs_to` 关联,给 `through` 的纪录手动设定。
187+
([Pull Request](https://github.com/rails/rails/pull/15754))
188+
189+
* 弃用 `serialized_attributes` without replacement.
190+
([Pull Request](https://github.com/rails/rails/pull/15704))
191+
167192
* 弃用了当栏位不存在时,还会从 `column_for_attribute` 返回 `nil` 的情况。
168193
Rails 5.0 将会返回 Null Object
169194
([Pull Request](https://github.com/rails/rails/pull/15878))
@@ -184,12 +209,27 @@ Active Record
184209

185210
([Commit](https://github.com/rails/rails/commit/91949e48cf41af9f3e4ffba3e5eecf9b0a08bfc3))
186211

187-
* 弃用对 `has_many :through` 自动侦测 counter cache 的支持。要自己对 `has_many`
188-
`belongs_to` 关联,给 `through` 的纪录手动设定。
189-
([Pull Request](https://github.com/rails/rails/pull/15754))
190-
191212
### 值得一提的变化
192213

214+
* 单数关联增加 `:required` 选项,用来定义关联的存在性验证。
215+
([Pull Request](https://github.com/rails/rails/pull/16056))
216+
217+
* 导入 `ActiveRecord::Base#validate!`,若记录不合法时会抛出 `RecordInvalid`
218+
([Pull Request](https://github.com/rails/rails/pull/8639))
219+
220+
* `ActiveRecord::Base#reload` 现在的行为同 `m = Model.find(m.id)`,代表不再给自定的
221+
`select` 保存额外的属性。
222+
([Pull Request](https://github.com/rails/rails/pull/15866))
223+
224+
* 导入 `bin/rake db:purge` 任务,用来清空当前环境的数据库。
225+
([Commit](https://github.com/rails/rails/commit/e2f232aba15937a4b9d14bd91e0392c6d55be58d))
226+
227+
* `ActiveRecord::Dirty` 现在会侦测可变数值的变化。序列化过的属性只在有变更时才会保存。
228+
修复了像是 PostgreSQL 不会侦测到字串或 JSON 栏位改变的问题。
229+
(Pull Requests [1](https://github.com/rails/rails/pull/15674),
230+
[2](https://github.com/rails/rails/pull/15786),
231+
[3](https://github.com/rails/rails/pull/15788))
232+
193233
* 新增 `ActiveRecord::Base` 对象的 `#pretty_print` 方法。
194234
([Pull Request](https://github.com/rails/rails/pull/15172))
195235

@@ -216,9 +256,6 @@ Active Record
216256
* 新增 PostgreSQL 适配器的使用自建的范围类型支持。
217257
([Commit](https://github.com/rails/rails/commit/4cb47167e747e8f9dc12b0ddaf82bdb68c03e032))
218258

219-
* 单数关联增加 `:required` 选项,用来定义关联的存在性验证。
220-
([Pull Request](https://github.com/rails/rails/pull/16056))
221-
222259
Active Model
223260
------------
224261

@@ -231,6 +268,12 @@ Active Model
231268

232269
### 值得一提的变化
233270

271+
* `ActiveModel::Dirty` 导入 `undo_changes` 方法,用来恢复变更的属性到先前的数值。
272+
([Pull Request](https://github.com/rails/rails/pull/14861))
273+
274+
* 若启用验证,`has_secure_password` 现在会检查密码是否少于 72 个字符。
275+
([Pull Request](https://github.com/rails/rails/pull/15708))
276+
234277
* 引入 `#validate` 作为 `#valid?` 的别名。
235278
([Pull Request](https://github.com/rails/rails/pull/14456))
236279

@@ -252,25 +295,22 @@ Active Support
252295
* 弃用 `Class#superclass_delegating_accessor`,请改用 `Class#class_attribute`
253296
([Pull Request](https://github.com/rails/rails/pull/14271))
254297

255-
* 弃用 `ActiveSupport::SafeBuffer#prepend!` 请改用 `ActiveSupport::SafeBuffer#prepend`两者功能相同)。
298+
* 弃用 `ActiveSupport::SafeBuffer#prepend!` 请改用 `ActiveSupport::SafeBuffer#prepend`两者特性相同)。
256299
([Pull Request](https://github.com/rails/rails/pull/14529))
257300

258301
### 值得一提的变化
259302

303+
* 新增 `Hash#transform_values``Hash#transform_values!` 方法,来简化 Hash
304+
值需要更新、但键保留不变这样的常见模式。
305+
([Pull Request](https://github.com/rails/rails/pull/15819))
306+
260307
* `humanize` 现在会去掉前面的底线。
261308
([Commit](https://github.com/rails/rails/commit/daaa21bc7d20f2e4ff451637423a25ff2d5e75c7))
262309

263-
* 新增 `SecureRandom::uuid_v3``SecureRandom::uuid_v5` 方法。
264-
([Pull Request](https://github.com/rails/rails/pull/12016))
265-
266310
* 导入 `Concern#class_methods` 来取代 `module ClassMethods` 以及 `Kernel#concern`
267311
来避免使用 `module Foo; extend ActiveSupport::Concern; end` 这样的样板。
268312
([Commit](https://github.com/rails/rails/commit/b16c36e688970df2f96f793a759365b248b582ad))
269313

270-
* 新增 `Hash#transform_values``Hash#transform_values!` 方法,来简化 Hash
271-
值需要更新、但键保留不变这样的常见模式。
272-
([Pull Request](https://github.com/rails/rails/pull/15819))
273-
274314
致谢
275315
----
276316

0 commit comments

Comments
 (0)