Skip to content

Commit 0673976

Browse files
committed
Sync with upstream.
1 parent ee88abc commit 0673976

16 files changed

+122
-52
lines changed

source/4_1_release_notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ By default, these preview classes live in `test/mailers/previews`.
157157
This can be configured using the `preview_path` option.
158158

159159
See its
160-
[documentation](http://api.rubyonrails.org/v4.1.0/classes/ActionMailer/Base.html)
160+
[documentation](http://api.rubyonrails.org/v4.1.0/classes/ActionMailer/Base.html#class-ActionMailer::Base-label-Previewing+emails)
161161
for a detailed write up.
162162

163163
### Active Record enums

source/4_2_release_notes.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ for a full description.
5555
Railties
5656
--------
5757

58-
Please refer to the
59-
[Changelog](https://github.com/rails/rails/blob/4-2-stable/railties/CHANGELOG.md)
60-
for detailed changes.
58+
Please refer to the [Changelog][railties] for detailed changes.
6159

6260
### Removals
6361

@@ -82,9 +80,7 @@ for detailed changes.
8280
Action Pack
8381
-----------
8482

85-
Please refer to the
86-
[Changelog](https://github.com/rails/rails/blob/4-2-stable/actionpack/CHANGELOG.md)
87-
for detailed changes.
83+
Please refer to the [Changelog][action-pack] for detailed changes.
8884

8985
### Deprecations
9086

@@ -143,9 +139,7 @@ for detailed changes.
143139
Action View
144140
-------------
145141

146-
Please refer to the
147-
[Changelog](https://github.com/rails/rails/blob/4-2-stable/actionview/CHANGELOG.md)
148-
for detailed changes.
142+
Please refer to the [Changelog][action-view] for detailed changes.
149143

150144
### Deprecations
151145

@@ -164,9 +158,7 @@ for detailed changes.
164158
Action Mailer
165159
-------------
166160

167-
Please refer to the
168-
[Changelog](https://github.com/rails/rails/blob/4-2-stable/actionmailer/CHANGELOG.md)
169-
for detailed changes.
161+
Please refer to the [Changelog][action-mailer] for detailed changes.
170162

171163
### Notable changes
172164

@@ -269,9 +261,7 @@ for detailed changes.
269261
Active Model
270262
------------
271263

272-
Please refer to the
273-
[Changelog](https://github.com/rails/rails/blob/4-2-stable/activemodel/CHANGELOG.md)
274-
for detailed changes.
264+
Please refer to the [Changelog][active-model] for detailed changes.
275265

276266
### Removals
277267

@@ -287,9 +277,7 @@ for detailed changes.
287277
Active Support
288278
--------------
289279

290-
Please refer to the
291-
[Changelog](https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md)
292-
for detailed changes.
280+
Please refer to the [Changelog][active-support] for detailed changes.
293281

294282
### Removals
295283

@@ -331,3 +319,11 @@ See the
331319
[full list of contributors to Rails](http://contributors.rubyonrails.org/) for
332320
the many people who spent many hours making Rails, the stable and robust
333321
framework it is. Kudos to all of them.
322+
323+
[railties]: https://github.com/rails/rails/blob/4-2-stable/railties/CHANGELOG.md
324+
[action-pack]: https://github.com/rails/rails/blob/4-2-stable/actionpack/CHANGELOG.md
325+
[action-view]: https://github.com/rails/rails/blob/4-2-stable/actionview/CHANGELOG.md
326+
[action-mailer]: https://github.com/rails/rails/blob/4-2-stable/actionmailer/CHANGELOG.md
327+
[active-record]: https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md
328+
[active-model]: https://github.com/rails/rails/blob/4-2-stable/activemodel/CHANGELOG.md
329+
[active-support]: https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md

source/active_model_basics.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,26 @@ person.valid? # => true
198198
person.token = nil
199199
person.valid? # => raises ActiveModel::StrictValidationFailed
200200
```
201+
202+
### ActiveModel::Naming
203+
204+
Naming adds a number of class methods which make the naming and routing
205+
easier to manage. The module defines the `model_name` class method which
206+
will define a number of accessors using some `ActiveSupport::Inflector` methods.
207+
208+
```ruby
209+
class Person
210+
extend ActiveModel::Naming
211+
end
212+
213+
Person.model_name.name # => "Person"
214+
Person.model_name.singular # => "person"
215+
Person.model_name.plural # => "people"
216+
Person.model_name.element # => "person"
217+
Person.model_name.human # => "Person"
218+
Person.model_name.collection # => "people"
219+
Person.model_name.param_key # => "person"
220+
Person.model_name.i18n_key # => :person
221+
Person.model_name.route_key # => "people"
222+
Person.model_name.singular_route_key # => "person"
223+
```

source/active_support_core_extensions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,9 +3672,9 @@ t.advance(seconds: 1)
36723672

36733673
#### `Time.current`
36743674

3675-
Active Support defines `Time.current` to be today in the current time zone. That's like `Time.now`, except that it honors the user time zone, if defined. It also defines `Time.yesterday` and `Time.tomorrow`, and the instance predicates `past?`, `today?`, and `future?`, all of them relative to `Time.current`.
3675+
Active Support defines `Time.current` to be today in the current time zone. That's like `Time.now`, except that it honors the user time zone, if defined. It also defines the instance predicates `past?`, `today?`, and `future?`, all of them relative to `Time.current`.
36763676

3677-
When making Time comparisons using methods which honor the user time zone, make sure to use `Time.current` and not `Time.now`. There are cases where the user time zone might be in the future compared to the system time zone, which `Time.today` uses by default. This means `Time.now` may equal `Time.yesterday`.
3677+
When making Time comparisons using methods which honor the user time zone, make sure to use `Time.current` instead of `Time.now`. There are cases where the user time zone might be in the future compared to the system time zone, which `Time.now` uses by default. This means `Time.now.to_date` may equal `Date.yesterday`.
36783678

36793679
#### `all_day`, `all_week`, `all_month`, `all_quarter` and `all_year`
36803680

source/command_line.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ With no further work, `rails server` will run our new shiny Rails app:
6262
$ cd commandsapp
6363
$ bin/rails server
6464
=> Booting WEBrick
65-
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
65+
=> Rails 4.2.0 application starting in development on http://0.0.0.0:3000
6666
=> Call with -d to detach
6767
=> Ctrl-C to shutdown server
6868
[2013-08-07 02:00:01] INFO WEBrick 1.3.1
@@ -289,7 +289,7 @@ If you wish to test out some code without changing any data, you can do that by
289289
290290
```bash
291291
$ bin/rails console --sandbox
292-
Loading development environment in sandbox (Rails 4.0.0)
292+
Loading development environment in sandbox (Rails 4.2.0)
293293
Any modifications you make will be rolled back on exit
294294
irb(main):001:0>
295295
```
@@ -402,13 +402,13 @@ About your application's environment
402402
Ruby version 1.9.3 (x86_64-linux)
403403
RubyGems version 1.3.6
404404
Rack version 1.3
405-
Rails version 4.1.1
405+
Rails version 4.2.0
406406
JavaScript Runtime Node.js (V8)
407-
Active Record version 4.1.1
408-
Action Pack version 4.1.1
409-
Action View version 4.1.1
410-
Action Mailer version 4.1.1
411-
Active Support version 4.1.1
407+
Active Record version 4.2.0
408+
Action Pack version 4.2.0
409+
Action View version 4.2.0
410+
Action Mailer version 4.2.0
411+
Active Support version 4.2.0
412412
Middleware Rack::Sendfile, ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007ffd131a7c88>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
413413
Application root /home/foobar/commandsapp
414414
Environment development

source/debugging_rails_applications.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ For example:
309309

310310
```bash
311311
=> Booting WEBrick
312-
=> Rails 4.1.1 application starting in development on http://0.0.0.0:3000
312+
=> Rails 4.2.0 application starting in development on http://0.0.0.0:3000
313313
=> Run `rails server -h` for more startup options
314314
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
315315
=> Ctrl-C to shutdown server
@@ -422,11 +422,11 @@ then `backtrace` will supply the answer.
422422
--> #0 ArticlesController.index
423423
at /PathTo/project/test_app/app/controllers/articles_controller.rb:8
424424
#1 ActionController::ImplicitRender.send_action(method#String, *args#Array)
425-
at /PathToGems/actionpack-4.1.1/lib/action_controller/metal/implicit_render.rb:4
425+
at /PathToGems/actionpack-4.2.0/lib/action_controller/metal/implicit_render.rb:4
426426
#2 AbstractController::Base.process_action(action#NilClass, *args#Array)
427-
at /PathToGems/actionpack-4.1.1/lib/abstract_controller/base.rb:189
427+
at /PathToGems/actionpack-4.2.0/lib/abstract_controller/base.rb:189
428428
#3 ActionController::Rendering.process_action(action#NilClass, *args#NilClass)
429-
at /PathToGems/actionpack-4.1.1/lib/action_controller/metal/rendering.rb:10
429+
at /PathToGems/actionpack-4.2.0/lib/action_controller/metal/rendering.rb:10
430430
...
431431
```
432432

@@ -438,7 +438,7 @@ context.
438438
```
439439
(byebug) frame 2
440440
441-
[184, 193] in /PathToGems/actionpack-4.1.1/lib/abstract_controller/base.rb
441+
[184, 193] in /PathToGems/actionpack-4.2.0/lib/abstract_controller/base.rb
442442
184: # is the intended way to override action dispatching.
443443
185: #
444444
186: # Notice that the first argument is the method to be dispatched
@@ -655,7 +655,7 @@ instruction to be executed. In this case, the activesupport's `week` method.
655655
```
656656
(byebug) step
657657
658-
[50, 59] in /PathToGems/activesupport-4.1.1/lib/active_support/core_ext/numeric/time.rb
658+
[50, 59] in /PathToGems/activesupport-4.2.0/lib/active_support/core_ext/numeric/time.rb
659659
50: ActiveSupport::Duration.new(self * 24.hours, [[:days, self]])
660660
51: end
661661
52: alias :day :days

source/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ run the following:
123123
$ bin/rails --version
124124
```
125125

126-
If it says something like "Rails 4.1.1", you are ready to continue.
126+
If it says something like "Rails 4.2.0", you are ready to continue.
127127

128128
### Creating the Blog Application
129129

source/i18n.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,11 @@ TIP: Right now you might need to add some more date/time formats in order to mak
437437

438438
### Inflection Rules For Other Locales
439439

440-
Rails 4.0 allows you to define inflection rules (such as rules for singularization and pluralization) for locales other than English. In `config/initializers/inflections.rb`, you can define these rules for multiple locales. The initializer contains a default example for specifying additional rules for English; follow that format for other locales as you see fit.
440+
Rails allows you to define inflection rules (such as rules for singularization and pluralization) for locales other than English. In `config/initializers/inflections.rb`, you can define these rules for multiple locales. The initializer contains a default example for specifying additional rules for English; follow that format for other locales as you see fit.
441441

442442
### Localized Views
443443

444-
Rails 2.3 introduces another convenient localization feature: localized views (templates). Let's say you have a _BooksController_ in your application. Your _index_ action renders content in `app/views/books/index.html.erb` template. When you put a _localized variant_ of this template: `index.es.html.erb` in the same directory, Rails will render content in this template, when the locale is set to `:es`. When the locale is set to the default locale, the generic `index.html.erb` view will be used. (Future Rails versions may well bring this _automagic_ localization to assets in `public`, etc.)
444+
Let's say you have a _BooksController_ in your application. Your _index_ action renders content in `app/views/books/index.html.erb` template. When you put a _localized variant_ of this template: `index.es.html.erb` in the same directory, Rails will render content in this template, when the locale is set to `:es`. When the locale is set to the default locale, the generic `index.html.erb` view will be used. (Future Rails versions may well bring this _automagic_ localization to assets in `public`, etc.)
445445

446446
You can make use of this feature, e.g. when working with a large amount of static content, which would be clumsy to put inside YAML or Ruby dictionaries. Bear in mind, though, that any change you would like to do later to the template must be propagated to all of them.
447447

source/upgrading_ruby_on_rails.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,20 @@ symbol access is no longer supported. This is also the case for
432432
`store_accessors` based on top of `json` or `hstore` columns. Make sure to use
433433
string keys consistently.
434434

435+
### Explicit block use for `ActiveSupport::Callbacks`
436+
437+
Rails 4.1 now expects an explicit block to be passed when calling
438+
`ActiveSupport::Callbacks.set_callback`. This change stems from
439+
`ActiveSupport::Callbacks` being largely rewritten for the 4.1 release.
440+
441+
```ruby
442+
# Previously in Rails 4.0
443+
set_callback :save, :around, ->(r, &block) { stuff; result = block.call; stuff }
444+
445+
# Now in Rails 4.1
446+
set_callback :save, :around, ->(r, block) { stuff; result = block.call; stuff }
447+
```
448+
435449
Upgrading from Rails 3.2 to Rails 4.0
436450
-------------------------------------
437451

source/zh-CN/4_1_release_notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ By default, these preview classes live in `test/mailers/previews`.
157157
This can be configured using the `preview_path` option.
158158

159159
See its
160-
[documentation](http://api.rubyonrails.org/v4.1.0/classes/ActionMailer/Base.html)
160+
[documentation](http://api.rubyonrails.org/v4.1.0/classes/ActionMailer/Base.html#class-ActionMailer::Base-label-Previewing+emails)
161161
for a detailed write up.
162162

163163
### Active Record enums

source/zh-CN/active_model_basics.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,26 @@ person.valid? # => true
198198
person.token = nil
199199
person.valid? # => raises ActiveModel::StrictValidationFailed
200200
```
201+
202+
### ActiveModel::Naming
203+
204+
Naming adds a number of class methods which make the naming and routing
205+
easier to manage. The module defines the `model_name` class method which
206+
will define a number of accessors using some `ActiveSupport::Inflector` methods.
207+
208+
```ruby
209+
class Person
210+
extend ActiveModel::Naming
211+
end
212+
213+
Person.model_name.name # => "Person"
214+
Person.model_name.singular # => "person"
215+
Person.model_name.plural # => "people"
216+
Person.model_name.element # => "person"
217+
Person.model_name.human # => "Person"
218+
Person.model_name.collection # => "people"
219+
Person.model_name.param_key # => "person"
220+
Person.model_name.i18n_key # => :person
221+
Person.model_name.route_key # => "people"
222+
Person.model_name.singular_route_key # => "person"
223+
```

source/zh-CN/command_line.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ $ rails new commandsapp
6262
$ cd commandsapp
6363
$ rails server
6464
=> Booting WEBrick
65-
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
65+
=> Rails 4.2.0 application starting in development on http://0.0.0.0:3000
6666
=> Call with -d to detach
6767
=> Ctrl-C to shutdown server
6868
[2013-08-07 02:00:01] INFO WEBrick 1.3.1
@@ -290,7 +290,7 @@ $ rails console staging
290290

291291
```bash
292292
$ rails console --sandbox
293-
Loading development environment in sandbox (Rails 4.0.0)
293+
Loading development environment in sandbox (Rails 4.2.0)
294294
Any modifications you make will be rolled back on exit
295295
irb(main):001:0>
296296
```
@@ -378,13 +378,13 @@ About your application's environment
378378
Ruby version 1.9.3 (x86_64-linux)
379379
RubyGems version 1.3.6
380380
Rack version 1.3
381-
Rails version 4.1.0
381+
Rails version 4.2.0
382382
JavaScript Runtime Node.js (V8)
383-
Active Record version 4.1.0
384-
Action Pack version 4.1.0
385-
Action View version 4.1.0
386-
Action Mailer version 4.1.0
387-
Active Support version 4.1.0
383+
Active Record version 4.2.0
384+
Action Pack version 4.2.0
385+
Action View version 4.2.0
386+
Action Mailer version 4.2.0
387+
Active Support version 4.2.0
388388
Middleware Rack::Sendfile, ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007ffd131a7c88>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
389389
Application root /home/foobar/commandsapp
390390
Environment development

source/zh-CN/debugging_rails_applications.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ end
257257
```bash
258258
$ rails server --debugger
259259
=> Booting WEBrick
260-
=> Rails 4.0.0 application starting on http://0.0.0.0:3000
260+
=> Rails 4.2.0 application starting on http://0.0.0.0:3000
261261
=> Debugger enabled
262262
...
263263
```
@@ -512,7 +512,7 @@ TIP: 在控制台中也可启用调试器,但要记得在调用 `debugger` 方
512512
513513
```bash
514514
$ rails console
515-
Loading development environment (Rails 4.0.0)
515+
Loading development environment (Rails 4.2.0)
516516
>> require "debugger"
517517
=> []
518518
>> author = Author.first

source/zh-CN/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ $ gem install rails
8282
$ rails --version
8383
```
8484

85-
如果显示的结果类似“Rails 4.1.0”,那么就可以继续往下读了。
85+
如果显示的结果类似“Rails 4.2.0”,那么就可以继续往下读了。
8686

8787
### 创建 Blog 程序
8888

source/zh-CN/i18n.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,11 @@ TIP: Right now you might need to add some more date/time formats in order to mak
438438

439439
### Inflection Rules For Other Locales
440440

441-
Rails 4.0 allows you to define inflection rules (such as rules for singularization and pluralization) for locales other than English. In `config/initializers/inflections.rb`, you can define these rules for multiple locales. The initializer contains a default example for specifying additional rules for English; follow that format for other locales as you see fit.
441+
Rails allows you to define inflection rules (such as rules for singularization and pluralization) for locales other than English. In `config/initializers/inflections.rb`, you can define these rules for multiple locales. The initializer contains a default example for specifying additional rules for English; follow that format for other locales as you see fit.
442442

443443
### Localized Views
444444

445-
Rails 2.3 introduces another convenient localization feature: localized views (templates). Let's say you have a _BooksController_ in your application. Your _index_ action renders content in `app/views/books/index.html.erb` template. When you put a _localized variant_ of this template: `index.es.html.erb` in the same directory, Rails will render content in this template, when the locale is set to `:es`. When the locale is set to the default locale, the generic `index.html.erb` view will be used. (Future Rails versions may well bring this _automagic_ localization to assets in `public`, etc.)
445+
Let's say you have a _BooksController_ in your application. Your _index_ action renders content in `app/views/books/index.html.erb` template. When you put a _localized variant_ of this template: `index.es.html.erb` in the same directory, Rails will render content in this template, when the locale is set to `:es`. When the locale is set to the default locale, the generic `index.html.erb` view will be used. (Future Rails versions may well bring this _automagic_ localization to assets in `public`, etc.)
446446

447447
You can make use of this feature, e.g. when working with a large amount of static content, which would be clumsy to put inside YAML or Ruby dictionaries. Bear in mind, though, that any change you would like to do later to the template must be propagated to all of them.
448448

source/zh-CN/upgrading_ruby_on_rails.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,20 @@ symbol access is no longer supported. This is also the case for
432432
`store_accessors` based on top of `json` or `hstore` columns. Make sure to use
433433
string keys consistently.
434434

435+
### Explicit block use for `ActiveSupport::Callbacks`
436+
437+
Rails 4.1 now expects an explicit block to be passed when calling
438+
`ActiveSupport::Callbacks.set_callback`. This change stems from
439+
`ActiveSupport::Callbacks` being largely rewritten for the 4.1 release.
440+
441+
```ruby
442+
# Previously in Rails 4.0
443+
set_callback :save, :around, ->(r, &block) { stuff; result = block.call; stuff }
444+
445+
# Now in Rails 4.1
446+
set_callback :save, :around, ->(r, block) { stuff; result = block.call; stuff }
447+
```
448+
435449
Upgrading from Rails 3.2 to Rails 4.0
436450
-------------------------------------
437451

0 commit comments

Comments
 (0)