rails 4.2.11.3 → 5.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +24 -12
- metadata +52 -244
- data/guides/CHANGELOG.md +0 -113
- data/guides/Rakefile +0 -92
- data/guides/assets/images/akshaysurve.jpg +0 -0
- data/guides/assets/images/belongs_to.png +0 -0
- data/guides/assets/images/book_icon.gif +0 -0
- data/guides/assets/images/bullet.gif +0 -0
- data/guides/assets/images/chapters_icon.gif +0 -0
- data/guides/assets/images/check_bullet.gif +0 -0
- data/guides/assets/images/credits_pic_blank.gif +0 -0
- data/guides/assets/images/csrf.png +0 -0
- data/guides/assets/images/edge_badge.png +0 -0
- data/guides/assets/images/favicon.ico +0 -0
- data/guides/assets/images/feature_tile.gif +0 -0
- data/guides/assets/images/footer_tile.gif +0 -0
- data/guides/assets/images/fxn.png +0 -0
- data/guides/assets/images/getting_started/article_with_comments.png +0 -0
- data/guides/assets/images/getting_started/challenge.png +0 -0
- data/guides/assets/images/getting_started/confirm_dialog.png +0 -0
- data/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
- data/guides/assets/images/getting_started/form_with_errors.png +0 -0
- data/guides/assets/images/getting_started/index_action_with_edit_link.png +0 -0
- data/guides/assets/images/getting_started/new_article.png +0 -0
- data/guides/assets/images/getting_started/rails_welcome.png +0 -0
- data/guides/assets/images/getting_started/routing_error_no_controller.png +0 -0
- data/guides/assets/images/getting_started/routing_error_no_route_matches.png +0 -0
- data/guides/assets/images/getting_started/show_action_for_articles.png +0 -0
- data/guides/assets/images/getting_started/template_is_missing_articles_new.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_create_for_articles.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_new_for_articles.png +0 -0
- data/guides/assets/images/grey_bullet.gif +0 -0
- data/guides/assets/images/habtm.png +0 -0
- data/guides/assets/images/has_many.png +0 -0
- data/guides/assets/images/has_many_through.png +0 -0
- data/guides/assets/images/has_one.png +0 -0
- data/guides/assets/images/has_one_through.png +0 -0
- data/guides/assets/images/header_backdrop.png +0 -0
- data/guides/assets/images/header_tile.gif +0 -0
- data/guides/assets/images/i18n/demo_html_safe.png +0 -0
- data/guides/assets/images/i18n/demo_localized_pirate.png +0 -0
- data/guides/assets/images/i18n/demo_translated_en.png +0 -0
- data/guides/assets/images/i18n/demo_translated_pirate.png +0 -0
- data/guides/assets/images/i18n/demo_translation_missing.png +0 -0
- data/guides/assets/images/i18n/demo_untranslated.png +0 -0
- data/guides/assets/images/icons/README +0 -5
- data/guides/assets/images/icons/callouts/1.png +0 -0
- data/guides/assets/images/icons/callouts/10.png +0 -0
- data/guides/assets/images/icons/callouts/11.png +0 -0
- data/guides/assets/images/icons/callouts/12.png +0 -0
- data/guides/assets/images/icons/callouts/13.png +0 -0
- data/guides/assets/images/icons/callouts/14.png +0 -0
- data/guides/assets/images/icons/callouts/15.png +0 -0
- data/guides/assets/images/icons/callouts/2.png +0 -0
- data/guides/assets/images/icons/callouts/3.png +0 -0
- data/guides/assets/images/icons/callouts/4.png +0 -0
- data/guides/assets/images/icons/callouts/5.png +0 -0
- data/guides/assets/images/icons/callouts/6.png +0 -0
- data/guides/assets/images/icons/callouts/7.png +0 -0
- data/guides/assets/images/icons/callouts/8.png +0 -0
- data/guides/assets/images/icons/callouts/9.png +0 -0
- data/guides/assets/images/icons/caution.png +0 -0
- data/guides/assets/images/icons/example.png +0 -0
- data/guides/assets/images/icons/home.png +0 -0
- data/guides/assets/images/icons/important.png +0 -0
- data/guides/assets/images/icons/next.png +0 -0
- data/guides/assets/images/icons/note.png +0 -0
- data/guides/assets/images/icons/prev.png +0 -0
- data/guides/assets/images/icons/tip.png +0 -0
- data/guides/assets/images/icons/up.png +0 -0
- data/guides/assets/images/icons/warning.png +0 -0
- data/guides/assets/images/nav_arrow.gif +0 -0
- data/guides/assets/images/oscardelben.jpg +0 -0
- data/guides/assets/images/polymorphic.png +0 -0
- data/guides/assets/images/radar.png +0 -0
- data/guides/assets/images/rails4_features.png +0 -0
- data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
- data/guides/assets/images/rails_guides_logo.gif +0 -0
- data/guides/assets/images/rails_logo_remix.gif +0 -0
- data/guides/assets/images/session_fixation.png +0 -0
- data/guides/assets/images/tab_grey.gif +0 -0
- data/guides/assets/images/tab_info.gif +0 -0
- data/guides/assets/images/tab_note.gif +0 -0
- data/guides/assets/images/tab_red.gif +0 -0
- data/guides/assets/images/tab_yellow.gif +0 -0
- data/guides/assets/images/tab_yellow.png +0 -0
- data/guides/assets/images/vijaydev.jpg +0 -0
- data/guides/assets/javascripts/guides.js +0 -59
- data/guides/assets/javascripts/jquery.min.js +0 -4
- data/guides/assets/javascripts/responsive-tables.js +0 -43
- data/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js +0 -59
- data/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js +0 -75
- data/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js +0 -59
- data/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js +0 -65
- data/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js +0 -100
- data/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js +0 -97
- data/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js +0 -91
- data/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js +0 -55
- data/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js +0 -41
- data/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js +0 -52
- data/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js +0 -67
- data/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js +0 -52
- data/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js +0 -57
- data/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js +0 -58
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js +0 -72
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js +0 -88
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js +0 -33
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js +0 -74
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js +0 -64
- data/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js +0 -55
- data/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js +0 -94
- data/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js +0 -51
- data/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js +0 -66
- data/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js +0 -56
- data/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js +0 -69
- data/guides/assets/javascripts/syntaxhighlighter/shCore.js +0 -17
- data/guides/assets/stylesheets/fixes.css +0 -16
- data/guides/assets/stylesheets/kindle.css +0 -11
- data/guides/assets/stylesheets/main.css +0 -713
- data/guides/assets/stylesheets/print.css +0 -52
- data/guides/assets/stylesheets/reset.css +0 -43
- data/guides/assets/stylesheets/responsive-tables.css +0 -50
- data/guides/assets/stylesheets/style.css +0 -13
- data/guides/assets/stylesheets/syntaxhighlighter/shCore.css +0 -226
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css +0 -328
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css +0 -331
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css +0 -339
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css +0 -324
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css +0 -324
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css +0 -324
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css +0 -324
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css +0 -117
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css +0 -120
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css +0 -128
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css +0 -113
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css +0 -113
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css +0 -113
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css +0 -113
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +0 -116
- data/guides/bug_report_templates/action_controller_gem.rb +0 -47
- data/guides/bug_report_templates/action_controller_master.rb +0 -54
- data/guides/bug_report_templates/active_record_gem.rb +0 -40
- data/guides/bug_report_templates/active_record_master.rb +0 -49
- data/guides/bug_report_templates/generic_gem.rb +0 -15
- data/guides/bug_report_templates/generic_master.rb +0 -26
- data/guides/rails_guides/generator.rb +0 -248
- data/guides/rails_guides/helpers.rb +0 -53
- data/guides/rails_guides/indexer.rb +0 -68
- data/guides/rails_guides/kindle.rb +0 -119
- data/guides/rails_guides/levenshtein.rb +0 -37
- data/guides/rails_guides/markdown/renderer.rb +0 -82
- data/guides/rails_guides/markdown.rb +0 -167
- data/guides/rails_guides.rb +0 -63
- data/guides/source/2_2_release_notes.md +0 -435
- data/guides/source/2_3_release_notes.md +0 -621
- data/guides/source/3_0_release_notes.md +0 -611
- data/guides/source/3_1_release_notes.md +0 -559
- data/guides/source/3_2_release_notes.md +0 -568
- data/guides/source/4_0_release_notes.md +0 -279
- data/guides/source/4_1_release_notes.md +0 -730
- data/guides/source/4_2_release_notes.md +0 -877
- data/guides/source/_license.html.erb +0 -2
- data/guides/source/_welcome.html.erb +0 -23
- data/guides/source/action_controller_overview.md +0 -1192
- data/guides/source/action_mailer_basics.md +0 -757
- data/guides/source/action_view_overview.md +0 -1561
- data/guides/source/active_job_basics.md +0 -339
- data/guides/source/active_model_basics.md +0 -554
- data/guides/source/active_record_basics.md +0 -374
- data/guides/source/active_record_callbacks.md +0 -413
- data/guides/source/active_record_migrations.md +0 -1018
- data/guides/source/active_record_postgresql.md +0 -433
- data/guides/source/active_record_querying.md +0 -1781
- data/guides/source/active_record_validations.md +0 -1179
- data/guides/source/active_support_core_extensions.md +0 -3856
- data/guides/source/active_support_instrumentation.md +0 -488
- data/guides/source/api_documentation_guidelines.md +0 -361
- data/guides/source/asset_pipeline.md +0 -1304
- data/guides/source/association_basics.md +0 -2245
- data/guides/source/autoloading_and_reloading_constants.md +0 -1311
- data/guides/source/caching_with_rails.md +0 -379
- data/guides/source/command_line.md +0 -625
- data/guides/source/configuring.md +0 -1070
- data/guides/source/contributing_to_ruby_on_rails.md +0 -628
- data/guides/source/credits.html.erb +0 -80
- data/guides/source/debugging_rails_applications.md +0 -861
- data/guides/source/development_dependencies_install.md +0 -289
- data/guides/source/documents.yaml +0 -205
- data/guides/source/engines.md +0 -1412
- data/guides/source/form_helpers.md +0 -1024
- data/guides/source/generators.md +0 -676
- data/guides/source/getting_started.md +0 -2086
- data/guides/source/i18n.md +0 -1087
- data/guides/source/index.html.erb +0 -28
- data/guides/source/initialization.md +0 -704
- data/guides/source/kindle/copyright.html.erb +0 -1
- data/guides/source/kindle/layout.html.erb +0 -27
- data/guides/source/kindle/rails_guides.opf.erb +0 -52
- data/guides/source/kindle/toc.html.erb +0 -24
- data/guides/source/kindle/toc.ncx.erb +0 -64
- data/guides/source/kindle/welcome.html.erb +0 -5
- data/guides/source/layout.html.erb +0 -140
- data/guides/source/layouts_and_rendering.md +0 -1226
- data/guides/source/maintenance_policy.md +0 -78
- data/guides/source/nested_model_forms.md +0 -228
- data/guides/source/plugins.md +0 -444
- data/guides/source/rails_application_templates.md +0 -266
- data/guides/source/rails_on_rack.md +0 -335
- data/guides/source/routing.md +0 -1155
- data/guides/source/ruby_on_rails_guides_guidelines.md +0 -127
- data/guides/source/security.md +0 -1024
- data/guides/source/testing.md +0 -1132
- data/guides/source/upgrading_ruby_on_rails.md +0 -1186
- data/guides/source/working_with_javascript_in_rails.md +0 -407
- data/guides/w3c_validator.rb +0 -97
@@ -1,877 +0,0 @@
|
|
1
|
-
Ruby on Rails 4.2 Release Notes
|
2
|
-
===============================
|
3
|
-
|
4
|
-
Highlights in Rails 4.2:
|
5
|
-
|
6
|
-
* Active Job
|
7
|
-
* Asynchronous mails
|
8
|
-
* Adequate Record
|
9
|
-
* Web Console
|
10
|
-
* Foreign key support
|
11
|
-
|
12
|
-
These release notes cover only the major changes. To learn about other
|
13
|
-
features, bug fixes, and changes, please refer to the changelogs or check out
|
14
|
-
the [list of commits](https://github.com/rails/rails/commits/4-2-stable) in
|
15
|
-
the main Rails repository on GitHub.
|
16
|
-
|
17
|
-
--------------------------------------------------------------------------------
|
18
|
-
|
19
|
-
Upgrading to Rails 4.2
|
20
|
-
----------------------
|
21
|
-
|
22
|
-
If you're upgrading an existing application, it's a great idea to have good test
|
23
|
-
coverage before going in. You should also first upgrade to Rails 4.1 in case you
|
24
|
-
haven't and make sure your application still runs as expected before attempting
|
25
|
-
to upgrade to Rails 4.2. A list of things to watch out for when upgrading is
|
26
|
-
available in the guide [Upgrading Ruby on
|
27
|
-
Rails](upgrading_ruby_on_rails.html#upgrading-from-rails-4-1-to-rails-4-2).
|
28
|
-
|
29
|
-
|
30
|
-
Major Features
|
31
|
-
--------------
|
32
|
-
|
33
|
-
### Active Job
|
34
|
-
|
35
|
-
Active Job is a new framework in Rails 4.2. It is a common interface on top of
|
36
|
-
queuing systems like [Resque](https://github.com/resque/resque), [Delayed
|
37
|
-
Job](https://github.com/collectiveidea/delayed_job),
|
38
|
-
[Sidekiq](https://github.com/mperham/sidekiq), and more.
|
39
|
-
|
40
|
-
Jobs written with the Active Job API run on any of the supported queues thanks
|
41
|
-
to their respective adapters. Active Job comes pre-configured with an inline
|
42
|
-
runner that executes jobs right away.
|
43
|
-
|
44
|
-
Jobs often need to take Active Record objects as arguments. Active Job passes
|
45
|
-
object references as URIs (uniform resource identifiers) instead of marshaling
|
46
|
-
the object itself. The new [Global ID](https://github.com/rails/globalid)
|
47
|
-
library builds URIs and looks up the objects they reference. Passing Active
|
48
|
-
Record objects as job arguments just works by using Global ID internally.
|
49
|
-
|
50
|
-
For example, if `trashable` is an Active Record object, then this job runs
|
51
|
-
just fine with no serialization involved:
|
52
|
-
|
53
|
-
```ruby
|
54
|
-
class TrashableCleanupJob < ActiveJob::Base
|
55
|
-
def perform(trashable, depth)
|
56
|
-
trashable.cleanup(depth)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
```
|
60
|
-
|
61
|
-
See the [Active Job Basics](active_job_basics.html) guide for more
|
62
|
-
information.
|
63
|
-
|
64
|
-
### Asynchronous Mails
|
65
|
-
|
66
|
-
Building on top of Active Job, Action Mailer now comes with a `deliver_later`
|
67
|
-
method that sends emails via the queue, so it doesn't block the controller or
|
68
|
-
model if the queue is asynchronous (the default inline queue blocks).
|
69
|
-
|
70
|
-
Sending emails right away is still possible with `deliver_now`.
|
71
|
-
|
72
|
-
### Adequate Record
|
73
|
-
|
74
|
-
Adequate Record is a set of performance improvements in Active Record that makes
|
75
|
-
common `find` and `find_by` calls and some association queries up to 2x faster.
|
76
|
-
|
77
|
-
It works by caching common SQL queries as prepared statements and reusing them
|
78
|
-
on similar calls, skipping most of the query-generation work on subsequent
|
79
|
-
calls. For more details, please refer to [Aaron Patterson's blog
|
80
|
-
post](http://tenderlovemaking.com/2014/02/19/adequaterecord-pro-like-activerecord.html).
|
81
|
-
|
82
|
-
Active Record will automatically take advantage of this feature on
|
83
|
-
supported operations without any user involvement or code changes. Here are
|
84
|
-
some examples of supported operations:
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
Post.find(1) # First call generates and cache the prepared statement
|
88
|
-
Post.find(2) # Subsequent calls reuse the cached prepared statement
|
89
|
-
|
90
|
-
Post.find_by_title('first post')
|
91
|
-
Post.find_by_title('second post')
|
92
|
-
|
93
|
-
Post.find_by(title: 'first post')
|
94
|
-
Post.find_by(title: 'second post')
|
95
|
-
|
96
|
-
post.comments
|
97
|
-
post.comments(true)
|
98
|
-
```
|
99
|
-
|
100
|
-
It's important to highlight that, as the examples above suggest, the prepared
|
101
|
-
statements do not cache the values passed in the method calls; rather, they
|
102
|
-
have placeholders for them.
|
103
|
-
|
104
|
-
Caching is not used in the following scenarios:
|
105
|
-
|
106
|
-
- The model has a default scope
|
107
|
-
- The model uses single table inheritance
|
108
|
-
- `find` with a list of ids, e.g.:
|
109
|
-
|
110
|
-
```ruby
|
111
|
-
# not cached
|
112
|
-
Post.find(1, 2, 3)
|
113
|
-
Post.find([1,2])
|
114
|
-
```
|
115
|
-
|
116
|
-
- `find_by` with SQL fragments:
|
117
|
-
|
118
|
-
```ruby
|
119
|
-
Post.find_by('published_at < ?', 2.weeks.ago)
|
120
|
-
```
|
121
|
-
|
122
|
-
### Web Console
|
123
|
-
|
124
|
-
New applications generated with Rails 4.2 now come with the [Web
|
125
|
-
Console](https://github.com/rails/web-console) gem by default. Web Console adds
|
126
|
-
an interactive Ruby console on every error page and provides a `console` view
|
127
|
-
and controller helpers.
|
128
|
-
|
129
|
-
The interactive console on error pages lets you execute code in the context of
|
130
|
-
the place where the exception originated. The `console` helper, if called
|
131
|
-
anywhere in a view or controller, launches an interactive console with the final
|
132
|
-
context, once rendering has completed.
|
133
|
-
|
134
|
-
### Foreign Key Support
|
135
|
-
|
136
|
-
The migration DSL now supports adding and removing foreign keys. They are dumped
|
137
|
-
to `schema.rb` as well. At this time, only the `mysql`, `mysql2` and `postgresql`
|
138
|
-
adapters support foreign keys.
|
139
|
-
|
140
|
-
```ruby
|
141
|
-
# add a foreign key to `articles.author_id` referencing `authors.id`
|
142
|
-
add_foreign_key :articles, :authors
|
143
|
-
|
144
|
-
# add a foreign key to `articles.author_id` referencing `users.lng_id`
|
145
|
-
add_foreign_key :articles, :users, column: :author_id, primary_key: "lng_id"
|
146
|
-
|
147
|
-
# remove the foreign key on `accounts.branch_id`
|
148
|
-
remove_foreign_key :accounts, :branches
|
149
|
-
|
150
|
-
# remove the foreign key on `accounts.owner_id`
|
151
|
-
remove_foreign_key :accounts, column: :owner_id
|
152
|
-
```
|
153
|
-
|
154
|
-
See the API documentation on
|
155
|
-
[add_foreign_key](http://api.rubyonrails.org/v4.2.0/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_foreign_key)
|
156
|
-
and
|
157
|
-
[remove_foreign_key](http://api.rubyonrails.org/v4.2.0/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-remove_foreign_key)
|
158
|
-
for a full description.
|
159
|
-
|
160
|
-
|
161
|
-
Incompatibilities
|
162
|
-
-----------------
|
163
|
-
|
164
|
-
Previously deprecated functionality has been removed. Please refer to the
|
165
|
-
individual components for new deprecations in this release.
|
166
|
-
|
167
|
-
The following changes may require immediate action upon upgrade.
|
168
|
-
|
169
|
-
### `render` with a String Argument
|
170
|
-
|
171
|
-
Previously, calling `render "foo/bar"` in a controller action was equivalent to
|
172
|
-
`render file: "foo/bar"`. In Rails 4.2, this has been changed to mean
|
173
|
-
`render template: "foo/bar"` instead. If you need to render a file, please
|
174
|
-
change your code to use the explicit form (`render file: "foo/bar"`) instead.
|
175
|
-
|
176
|
-
### `respond_with` / Class-Level `respond_to`
|
177
|
-
|
178
|
-
`respond_with` and the corresponding class-level `respond_to` have been moved
|
179
|
-
to the [responders](https://github.com/plataformatec/responders) gem. Add
|
180
|
-
`gem 'responders', '~> 2.0'` to your Gemfile to use it:
|
181
|
-
|
182
|
-
```ruby
|
183
|
-
# app/controllers/users_controller.rb
|
184
|
-
|
185
|
-
class UsersController < ApplicationController
|
186
|
-
respond_to :html, :json
|
187
|
-
|
188
|
-
def show
|
189
|
-
@user = User.find(params[:id])
|
190
|
-
respond_with @user
|
191
|
-
end
|
192
|
-
end
|
193
|
-
```
|
194
|
-
|
195
|
-
Instance-level `respond_to` is unaffected:
|
196
|
-
|
197
|
-
```ruby
|
198
|
-
# app/controllers/users_controller.rb
|
199
|
-
|
200
|
-
class UsersController < ApplicationController
|
201
|
-
def show
|
202
|
-
@user = User.find(params[:id])
|
203
|
-
respond_to do |format|
|
204
|
-
format.html
|
205
|
-
format.json { render json: @user }
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
```
|
210
|
-
|
211
|
-
### Default Host for `rails server`
|
212
|
-
|
213
|
-
Due to a [change in Rack](https://github.com/rack/rack/commit/28b014484a8ac0bbb388e7eaeeef159598ec64fc),
|
214
|
-
`rails server` now listens on `localhost` instead of `0.0.0.0` by default. This
|
215
|
-
should have minimal impact on the standard development workflow as both
|
216
|
-
http://127.0.0.1:3000 and http://localhost:3000 will continue to work as before
|
217
|
-
on your own machine.
|
218
|
-
|
219
|
-
However, with this change you will no longer be able to access the Rails
|
220
|
-
server from a different machine, for example if your development environment
|
221
|
-
is in a virtual machine and you would like to access it from the host machine.
|
222
|
-
In such cases, please start the server with `rails server -b 0.0.0.0` to
|
223
|
-
restore the old behavior.
|
224
|
-
|
225
|
-
If you do this, be sure to configure your firewall properly such that only
|
226
|
-
trusted machines on your network can access your development server.
|
227
|
-
|
228
|
-
### HTML Sanitizer
|
229
|
-
|
230
|
-
The HTML sanitizer has been replaced with a new, more robust, implementation
|
231
|
-
built upon [Loofah](https://github.com/flavorjones/loofah) and
|
232
|
-
[Nokogiri](https://github.com/sparklemotion/nokogiri). The new sanitizer is
|
233
|
-
more secure and its sanitization is more powerful and flexible.
|
234
|
-
|
235
|
-
Due to the new algorithm, the sanitized output may be different for certain
|
236
|
-
pathological inputs.
|
237
|
-
|
238
|
-
If you have a particular need for the exact output of the old sanitizer, you
|
239
|
-
can add the [rails-deprecated_sanitizer](https://github.com/kaspth/rails-deprecated_sanitizer)
|
240
|
-
gem to the `Gemfile`, to have the old behavior. The gem does not issue
|
241
|
-
deprecation warnings because it is opt-in.
|
242
|
-
|
243
|
-
`rails-deprecated_sanitizer` will be supported for Rails 4.2 only; it will not
|
244
|
-
be maintained for Rails 5.0.
|
245
|
-
|
246
|
-
See [this blog post](http://blog.plataformatec.com.br/2014/07/the-new-html-sanitizer-in-rails-4-2/)
|
247
|
-
for more details on the changes in the new sanitizer.
|
248
|
-
|
249
|
-
### `assert_select`
|
250
|
-
|
251
|
-
`assert_select` is now based on [Nokogiri](https://github.com/sparklemotion/nokogiri).
|
252
|
-
As a result, some previously-valid selectors are now unsupported. If your
|
253
|
-
application is using any of these spellings, you will need to update them:
|
254
|
-
|
255
|
-
* Values in attribute selectors may need to be quoted if they contain
|
256
|
-
non-alphanumeric characters.
|
257
|
-
|
258
|
-
```
|
259
|
-
# before
|
260
|
-
a[href=/]
|
261
|
-
a[href$=/]
|
262
|
-
|
263
|
-
# now
|
264
|
-
a[href="/"]
|
265
|
-
a[href$="/"]
|
266
|
-
```
|
267
|
-
|
268
|
-
* DOMs built from HTML source containing invalid HTML with improperly
|
269
|
-
nested elements may differ.
|
270
|
-
|
271
|
-
For example:
|
272
|
-
|
273
|
-
``` ruby
|
274
|
-
# content: <div><i><p></i></div>
|
275
|
-
|
276
|
-
# before:
|
277
|
-
assert_select('div > i') # => true
|
278
|
-
assert_select('div > p') # => false
|
279
|
-
assert_select('i > p') # => true
|
280
|
-
|
281
|
-
# now:
|
282
|
-
assert_select('div > i') # => true
|
283
|
-
assert_select('div > p') # => true
|
284
|
-
assert_select('i > p') # => false
|
285
|
-
```
|
286
|
-
|
287
|
-
* If the data selected contains entities, the value selected for comparison
|
288
|
-
used to be raw (e.g. `AT&T`), and now is evaluated
|
289
|
-
(e.g. `AT&T`).
|
290
|
-
|
291
|
-
``` ruby
|
292
|
-
# content: <p>AT&T</p>
|
293
|
-
|
294
|
-
# before:
|
295
|
-
assert_select('p', 'AT&T') # => true
|
296
|
-
assert_select('p', 'AT&T') # => false
|
297
|
-
|
298
|
-
# now:
|
299
|
-
assert_select('p', 'AT&T') # => true
|
300
|
-
assert_select('p', 'AT&T') # => false
|
301
|
-
```
|
302
|
-
|
303
|
-
Furthermore substitutions have changed syntax.
|
304
|
-
|
305
|
-
Now you have to use a `:match` CSS-like selector:
|
306
|
-
|
307
|
-
```ruby
|
308
|
-
assert_select ":match('id', ?)", 'comment_1'
|
309
|
-
```
|
310
|
-
|
311
|
-
Additionally Regexp substitutions look different when the assertion fails.
|
312
|
-
Notice how `/hello/` here:
|
313
|
-
|
314
|
-
```ruby
|
315
|
-
assert_select(":match('id', ?)", /hello/)
|
316
|
-
```
|
317
|
-
|
318
|
-
becomes `"(?-mix:hello)"`:
|
319
|
-
|
320
|
-
```
|
321
|
-
Expected at least 1 element matching "div:match('id', "(?-mix:hello)")", found 0..
|
322
|
-
Expected 0 to be >= 1.
|
323
|
-
```
|
324
|
-
|
325
|
-
See the [Rails Dom Testing](https://github.com/rails/rails-dom-testing/tree/8798b9349fb9540ad8cb9a0ce6cb88d1384a210b) documentation for more on `assert_select`.
|
326
|
-
|
327
|
-
|
328
|
-
Railties
|
329
|
-
--------
|
330
|
-
|
331
|
-
Please refer to the [Changelog][railties] for detailed changes.
|
332
|
-
|
333
|
-
### Removals
|
334
|
-
|
335
|
-
* The `--skip-action-view` option has been removed from the
|
336
|
-
app generator. ([Pull Request](https://github.com/rails/rails/pull/17042))
|
337
|
-
|
338
|
-
* The `rails application` command has been removed without replacement.
|
339
|
-
([Pull Request](https://github.com/rails/rails/pull/11616))
|
340
|
-
|
341
|
-
### Deprecations
|
342
|
-
|
343
|
-
* Deprecated missing `config.log_level` for production environments.
|
344
|
-
([Pull Request](https://github.com/rails/rails/pull/16622))
|
345
|
-
|
346
|
-
* Deprecated `rake test:all` in favor of `rake test` as it now run all tests
|
347
|
-
in the `test` folder.
|
348
|
-
([Pull Request](https://github.com/rails/rails/pull/17348))
|
349
|
-
|
350
|
-
* Deprecated `rake test:all:db` in favor of `rake test:db`.
|
351
|
-
([Pull Request](https://github.com/rails/rails/pull/17348))
|
352
|
-
|
353
|
-
* Deprecated `Rails::Rack::LogTailer` without replacement.
|
354
|
-
([Commit](https://github.com/rails/rails/commit/84a13e019e93efaa8994b3f8303d635a7702dbce))
|
355
|
-
|
356
|
-
### Notable changes
|
357
|
-
|
358
|
-
* Introduced `web-console` in the default application Gemfile.
|
359
|
-
([Pull Request](https://github.com/rails/rails/pull/11667))
|
360
|
-
|
361
|
-
* Added a `required` option to the model generator for associations.
|
362
|
-
([Pull Request](https://github.com/rails/rails/pull/16062))
|
363
|
-
|
364
|
-
* Introduced the `x` namespace for defining custom configuration options:
|
365
|
-
|
366
|
-
```ruby
|
367
|
-
# config/environments/production.rb
|
368
|
-
config.x.payment_processing.schedule = :daily
|
369
|
-
config.x.payment_processing.retries = 3
|
370
|
-
config.x.super_debugger = true
|
371
|
-
```
|
372
|
-
|
373
|
-
These options are then available through the configuration object:
|
374
|
-
|
375
|
-
```ruby
|
376
|
-
Rails.configuration.x.payment_processing.schedule # => :daily
|
377
|
-
Rails.configuration.x.payment_processing.retries # => 3
|
378
|
-
Rails.configuration.x.super_debugger # => true
|
379
|
-
```
|
380
|
-
|
381
|
-
([Commit](https://github.com/rails/rails/commit/611849772dd66c2e4d005dcfe153f7ce79a8a7db))
|
382
|
-
|
383
|
-
* Introduced `Rails::Application.config_for` to load a configuration for the
|
384
|
-
current environment.
|
385
|
-
|
386
|
-
```ruby
|
387
|
-
# config/exception_notification.yml:
|
388
|
-
production:
|
389
|
-
url: http://127.0.0.1:8080
|
390
|
-
namespace: my_app_production
|
391
|
-
development:
|
392
|
-
url: http://localhost:3001
|
393
|
-
namespace: my_app_development
|
394
|
-
|
395
|
-
# config/production.rb
|
396
|
-
Rails.application.configure do
|
397
|
-
config.middleware.use ExceptionNotifier, config_for(:exception_notification)
|
398
|
-
end
|
399
|
-
```
|
400
|
-
|
401
|
-
([Pull Request](https://github.com/rails/rails/pull/16129))
|
402
|
-
|
403
|
-
* Introduced a `--skip-turbolinks` option in the app generator to not generate
|
404
|
-
turbolinks integration.
|
405
|
-
([Commit](https://github.com/rails/rails/commit/bf17c8a531bc8059d50ad731398002a3e7162a7d))
|
406
|
-
|
407
|
-
* Introduced a `bin/setup` script as a convention for automated setup code when
|
408
|
-
bootstrapping an application.
|
409
|
-
([Pull Request](https://github.com/rails/rails/pull/15189))
|
410
|
-
|
411
|
-
* Changed the default value for `config.assets.digest` to `true` in development.
|
412
|
-
([Pull Request](https://github.com/rails/rails/pull/15155))
|
413
|
-
|
414
|
-
* Introduced an API to register new extensions for `rake notes`.
|
415
|
-
([Pull Request](https://github.com/rails/rails/pull/14379))
|
416
|
-
|
417
|
-
* Introduced an `after_bundle` callback for use in Rails templates.
|
418
|
-
([Pull Request](https://github.com/rails/rails/pull/16359))
|
419
|
-
|
420
|
-
* Introduced `Rails.gem_version` as a convenience method to return
|
421
|
-
`Gem::Version.new(Rails.version)`.
|
422
|
-
([Pull Request](https://github.com/rails/rails/pull/14101))
|
423
|
-
|
424
|
-
|
425
|
-
Action Pack
|
426
|
-
-----------
|
427
|
-
|
428
|
-
Please refer to the [Changelog][action-pack] for detailed changes.
|
429
|
-
|
430
|
-
### Removals
|
431
|
-
|
432
|
-
* `respond_with` and the class-level `respond_to` have been removed from Rails and
|
433
|
-
moved to the `responders` gem (version 2.0). Add `gem 'responders', '~> 2.0'`
|
434
|
-
to your `Gemfile` to continue using these features.
|
435
|
-
([Pull Request](https://github.com/rails/rails/pull/16526),
|
436
|
-
[More Details](http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#responders))
|
437
|
-
|
438
|
-
* Removed deprecated `AbstractController::Helpers::ClassMethods::MissingHelperError`
|
439
|
-
in favor of `AbstractController::Helpers::MissingHelperError`.
|
440
|
-
([Commit](https://github.com/rails/rails/commit/a1ddde15ae0d612ff2973de9cf768ed701b594e8))
|
441
|
-
|
442
|
-
### Deprecations
|
443
|
-
|
444
|
-
* Deprecated the `only_path` option on `*_path` helpers.
|
445
|
-
([Commit](https://github.com/rails/rails/commit/aa1fadd48fb40dd9396a383696134a259aa59db9))
|
446
|
-
|
447
|
-
* Deprecated `assert_tag`, `assert_no_tag`, `find_tag` and `find_all_tag` in
|
448
|
-
favor of `assert_select`.
|
449
|
-
([Commit](https://github.com/rails/rails-dom-testing/commit/b12850bc5ff23ba4b599bf2770874dd4f11bf750))
|
450
|
-
|
451
|
-
* Deprecated support for setting the `:to` option of a router to a symbol or a
|
452
|
-
string that does not contain a "#" character:
|
453
|
-
|
454
|
-
```ruby
|
455
|
-
get '/posts', to: MyRackApp => (No change necessary)
|
456
|
-
get '/posts', to: 'post#index' => (No change necessary)
|
457
|
-
get '/posts', to: 'posts' => get '/posts', controller: :posts
|
458
|
-
get '/posts', to: :index => get '/posts', action: :index
|
459
|
-
```
|
460
|
-
|
461
|
-
([Commit](https://github.com/rails/rails/commit/cc26b6b7bccf0eea2e2c1a9ebdcc9d30ca7390d9))
|
462
|
-
|
463
|
-
* Deprecated support for string keys in URL helpers:
|
464
|
-
|
465
|
-
```ruby
|
466
|
-
# bad
|
467
|
-
root_path('controller' => 'posts', 'action' => 'index')
|
468
|
-
|
469
|
-
# good
|
470
|
-
root_path(controller: 'posts', action: 'index')
|
471
|
-
```
|
472
|
-
|
473
|
-
([Pull Request](https://github.com/rails/rails/pull/17743))
|
474
|
-
|
475
|
-
### Notable changes
|
476
|
-
|
477
|
-
* The `*_filter` family of methods have been removed from the documentation. Their
|
478
|
-
usage is discouraged in favor of the `*_action` family of methods:
|
479
|
-
|
480
|
-
```
|
481
|
-
after_filter => after_action
|
482
|
-
append_after_filter => append_after_action
|
483
|
-
append_around_filter => append_around_action
|
484
|
-
append_before_filter => append_before_action
|
485
|
-
around_filter => around_action
|
486
|
-
before_filter => before_action
|
487
|
-
prepend_after_filter => prepend_after_action
|
488
|
-
prepend_around_filter => prepend_around_action
|
489
|
-
prepend_before_filter => prepend_before_action
|
490
|
-
skip_after_filter => skip_after_action
|
491
|
-
skip_around_filter => skip_around_action
|
492
|
-
skip_before_filter => skip_before_action
|
493
|
-
skip_filter => skip_action_callback
|
494
|
-
```
|
495
|
-
|
496
|
-
If your application currently depends on these methods, you should use the
|
497
|
-
replacement `*_action` methods instead. These methods will be deprecated in
|
498
|
-
the future and will eventually be removed from Rails.
|
499
|
-
|
500
|
-
(Commit [1](https://github.com/rails/rails/commit/6c5f43bab8206747a8591435b2aa0ff7051ad3de),
|
501
|
-
[2](https://github.com/rails/rails/commit/489a8f2a44dc9cea09154ee1ee2557d1f037c7d4))
|
502
|
-
|
503
|
-
* `render nothing: true` or rendering a `nil` body no longer add a single
|
504
|
-
space padding to the response body.
|
505
|
-
([Pull Request](https://github.com/rails/rails/pull/14883))
|
506
|
-
|
507
|
-
* Rails now automatically includes the template's digest in ETags.
|
508
|
-
([Pull Request](https://github.com/rails/rails/pull/16527))
|
509
|
-
|
510
|
-
* Segments that are passed into URL helpers are now automatically escaped.
|
511
|
-
([Commit](https://github.com/rails/rails/commit/5460591f0226a9d248b7b4f89186bd5553e7768f))
|
512
|
-
|
513
|
-
* Introduced the `always_permitted_parameters` option to configure which
|
514
|
-
parameters are permitted globally. The default value of this configuration
|
515
|
-
is `['controller', 'action']`.
|
516
|
-
([Pull Request](https://github.com/rails/rails/pull/15933))
|
517
|
-
|
518
|
-
* Added the HTTP method `MKCALENDAR` from [RFC 4791](https://tools.ietf.org/html/rfc4791).
|
519
|
-
([Pull Request](https://github.com/rails/rails/pull/15121))
|
520
|
-
|
521
|
-
* `*_fragment.action_controller` notifications now include the controller
|
522
|
-
and action name in the payload.
|
523
|
-
([Pull Request](https://github.com/rails/rails/pull/14137))
|
524
|
-
|
525
|
-
* Improved the Routing Error page with fuzzy matching for route search.
|
526
|
-
([Pull Request](https://github.com/rails/rails/pull/14619))
|
527
|
-
|
528
|
-
* Added an option to disable logging of CSRF failures.
|
529
|
-
([Pull Request](https://github.com/rails/rails/pull/14280))
|
530
|
-
|
531
|
-
* When the Rails server is set to serve static assets, gzip assets will now be
|
532
|
-
served if the client supports it and a pre-generated gzip file (`.gz`) is on disk.
|
533
|
-
By default the asset pipeline generates `.gz` files for all compressible assets.
|
534
|
-
Serving gzip files minimizes data transfer and speeds up asset requests. Always
|
535
|
-
[use a CDN](http://guides.rubyonrails.org/asset_pipeline.html#cdns) if you are
|
536
|
-
serving assets from your Rails server in production.
|
537
|
-
([Pull Request](https://github.com/rails/rails/pull/16466))
|
538
|
-
|
539
|
-
* When calling the `process` helpers in an integration test the path needs to have
|
540
|
-
a leading slash. Previously you could omit it but that was a byproduct of the
|
541
|
-
implementation and not an intentional feature, e.g.:
|
542
|
-
|
543
|
-
```ruby
|
544
|
-
test "list all posts" do
|
545
|
-
get "/posts"
|
546
|
-
assert_response :success
|
547
|
-
end
|
548
|
-
```
|
549
|
-
|
550
|
-
Action View
|
551
|
-
-----------
|
552
|
-
|
553
|
-
Please refer to the [Changelog][action-view] for detailed changes.
|
554
|
-
|
555
|
-
### Deprecations
|
556
|
-
|
557
|
-
* Deprecated `AbstractController::Base.parent_prefixes`.
|
558
|
-
Override `AbstractController::Base.local_prefixes` when you want to change
|
559
|
-
where to find views.
|
560
|
-
([Pull Request](https://github.com/rails/rails/pull/15026))
|
561
|
-
|
562
|
-
* Deprecated `ActionView::Digestor#digest(name, format, finder, options = {})`.
|
563
|
-
Arguments should be passed as a hash instead.
|
564
|
-
([Pull Request](https://github.com/rails/rails/pull/14243))
|
565
|
-
|
566
|
-
### Notable changes
|
567
|
-
|
568
|
-
* `render "foo/bar"` now expands to `render template: "foo/bar"` instead of
|
569
|
-
`render file: "foo/bar"`.
|
570
|
-
([Pull Request](https://github.com/rails/rails/pull/16888))
|
571
|
-
|
572
|
-
* The form helpers no longer generate a `<div>` element with inline CSS around
|
573
|
-
the hidden fields.
|
574
|
-
([Pull Request](https://github.com/rails/rails/pull/14738))
|
575
|
-
|
576
|
-
* Introduced a `#{partial_name}_iteration` special local variable for use with
|
577
|
-
partials that are rendered with a collection. It provides access to the
|
578
|
-
current state of the iteration via the `index`, `size`, `first?` and
|
579
|
-
`last?` methods.
|
580
|
-
([Pull Request](https://github.com/rails/rails/pull/7698))
|
581
|
-
|
582
|
-
* Placeholder I18n follows the same convention as `label` I18n.
|
583
|
-
([Pull Request](https://github.com/rails/rails/pull/16438))
|
584
|
-
|
585
|
-
|
586
|
-
Action Mailer
|
587
|
-
-------------
|
588
|
-
|
589
|
-
Please refer to the [Changelog][action-mailer] for detailed changes.
|
590
|
-
|
591
|
-
### Deprecations
|
592
|
-
|
593
|
-
* Deprecated `*_path` helpers in mailers. Always use `*_url` helpers instead.
|
594
|
-
([Pull Request](https://github.com/rails/rails/pull/15840))
|
595
|
-
|
596
|
-
* Deprecated `deliver` / `deliver!` in favor of `deliver_now` / `deliver_now!`.
|
597
|
-
([Pull Request](https://github.com/rails/rails/pull/16582))
|
598
|
-
|
599
|
-
### Notable changes
|
600
|
-
|
601
|
-
* `link_to` and `url_for` generate absolute URLs by default in templates,
|
602
|
-
it is no longer needed to pass `only_path: false`.
|
603
|
-
([Commit](https://github.com/rails/rails/commit/9685080a7677abfa5d288a81c3e078368c6bb67c))
|
604
|
-
|
605
|
-
* Introduced `deliver_later` which enqueues a job on the application's queue
|
606
|
-
to deliver emails asynchronously.
|
607
|
-
([Pull Request](https://github.com/rails/rails/pull/16485))
|
608
|
-
|
609
|
-
* Added the `show_previews` configuration option for enabling mailer previews
|
610
|
-
outside of the development environment.
|
611
|
-
([Pull Request](https://github.com/rails/rails/pull/15970))
|
612
|
-
|
613
|
-
|
614
|
-
Active Record
|
615
|
-
-------------
|
616
|
-
|
617
|
-
Please refer to the [Changelog][active-record] for detailed changes.
|
618
|
-
|
619
|
-
### Removals
|
620
|
-
|
621
|
-
* Removed `cache_attributes` and friends. All attributes are cached.
|
622
|
-
([Pull Request](https://github.com/rails/rails/pull/15429))
|
623
|
-
|
624
|
-
* Removed deprecated method `ActiveRecord::Base.quoted_locking_column`.
|
625
|
-
([Pull Request](https://github.com/rails/rails/pull/15612))
|
626
|
-
|
627
|
-
* Removed deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
|
628
|
-
`proper_table_name` instance method on `ActiveRecord::Migration` instead.
|
629
|
-
([Pull Request](https://github.com/rails/rails/pull/15512))
|
630
|
-
|
631
|
-
* Removed unused `:timestamp` type. Transparently alias it to `:datetime`
|
632
|
-
in all cases. Fixes inconsistencies when column types are sent outside of
|
633
|
-
Active Record, such as for XML serialization.
|
634
|
-
([Pull Request](https://github.com/rails/rails/pull/15184))
|
635
|
-
|
636
|
-
### Deprecations
|
637
|
-
|
638
|
-
* Deprecated swallowing of errors inside `after_commit` and `after_rollback`.
|
639
|
-
([Pull Request](https://github.com/rails/rails/pull/16537))
|
640
|
-
|
641
|
-
* Deprecated broken support for automatic detection of counter caches on
|
642
|
-
`has_many :through` associations. You should instead manually specify the
|
643
|
-
counter cache on the `has_many` and `belongs_to` associations for the
|
644
|
-
through records.
|
645
|
-
([Pull Request](https://github.com/rails/rails/pull/15754))
|
646
|
-
|
647
|
-
* Deprecated passing Active Record objects to `.find` or `.exists?`. Call
|
648
|
-
`id` on the objects first.
|
649
|
-
(Commit [1](https://github.com/rails/rails/commit/d92ae6ccca3bcfd73546d612efaea011270bd270),
|
650
|
-
[2](https://github.com/rails/rails/commit/d35f0033c7dec2b8d8b52058fb8db495d49596f7))
|
651
|
-
|
652
|
-
* Deprecated half-baked support for PostgreSQL range values with excluding
|
653
|
-
beginnings. We currently map PostgreSQL ranges to Ruby ranges. This conversion
|
654
|
-
is not fully possible because Ruby ranges do not support excluded beginnings.
|
655
|
-
|
656
|
-
The current solution of incrementing the beginning is not correct
|
657
|
-
and is now deprecated. For subtypes where we don't know how to increment
|
658
|
-
(e.g. `succ` is not defined) it will raise an `ArgumentError` for ranges
|
659
|
-
with excluding beginnings.
|
660
|
-
([Commit](https://github.com/rails/rails/commit/91949e48cf41af9f3e4ffba3e5eecf9b0a08bfc3))
|
661
|
-
|
662
|
-
* Deprecated calling `DatabaseTasks.load_schema` without a connection. Use
|
663
|
-
`DatabaseTasks.load_schema_current` instead.
|
664
|
-
([Commit](https://github.com/rails/rails/commit/f15cef67f75e4b52fd45655d7c6ab6b35623c608))
|
665
|
-
|
666
|
-
* Deprecated `sanitize_sql_hash_for_conditions` without replacement. Using a
|
667
|
-
`Relation` for performing queries and updates is the preferred API.
|
668
|
-
([Commit](https://github.com/rails/rails/commit/d5902c9e))
|
669
|
-
|
670
|
-
* Deprecated `add_timestamps` and `t.timestamps` without passing the `:null`
|
671
|
-
option. The default of `null: true` will change in Rails 5 to `null: false`.
|
672
|
-
([Pull Request](https://github.com/rails/rails/pull/16481))
|
673
|
-
|
674
|
-
* Deprecated `Reflection#source_macro` without replacement as it is no longer
|
675
|
-
needed in Active Record.
|
676
|
-
([Pull Request](https://github.com/rails/rails/pull/16373))
|
677
|
-
|
678
|
-
* Deprecated `serialized_attributes` without replacement.
|
679
|
-
([Pull Request](https://github.com/rails/rails/pull/15704))
|
680
|
-
|
681
|
-
* Deprecated returning `nil` from `column_for_attribute` when no column
|
682
|
-
exists. It will return a null object in Rails 5.0.
|
683
|
-
([Pull Request](https://github.com/rails/rails/pull/15878))
|
684
|
-
|
685
|
-
* Deprecated using `.joins`, `.preload` and `.eager_load` with associations
|
686
|
-
that depend on the instance state (i.e. those defined with a scope that
|
687
|
-
takes an argument) without replacement.
|
688
|
-
([Commit](https://github.com/rails/rails/commit/ed56e596a0467390011bc9d56d462539776adac1))
|
689
|
-
|
690
|
-
### Notable changes
|
691
|
-
|
692
|
-
* `SchemaDumper` uses `force: :cascade` on `create_table`. This makes it
|
693
|
-
possible to reload a schema when foreign keys are in place.
|
694
|
-
|
695
|
-
* Added a `:required` option to singular associations, which defines a
|
696
|
-
presence validation on the association.
|
697
|
-
([Pull Request](https://github.com/rails/rails/pull/16056))
|
698
|
-
|
699
|
-
* `ActiveRecord::Dirty` now detects in-place changes to mutable values.
|
700
|
-
Serialized attributes on Active Record models are no longer saved when
|
701
|
-
unchanged. This also works with other types such as string columns and json
|
702
|
-
columns on PostgreSQL.
|
703
|
-
(Pull Requests [1](https://github.com/rails/rails/pull/15674),
|
704
|
-
[2](https://github.com/rails/rails/pull/15786),
|
705
|
-
[3](https://github.com/rails/rails/pull/15788))
|
706
|
-
|
707
|
-
* Introduced the `db:purge` Rake task to empty the database for the
|
708
|
-
current environment.
|
709
|
-
([Commit](https://github.com/rails/rails/commit/e2f232aba15937a4b9d14bd91e0392c6d55be58d))
|
710
|
-
|
711
|
-
* Introduced `ActiveRecord::Base#validate!` that raises
|
712
|
-
`ActiveRecord::RecordInvalid` if the record is invalid.
|
713
|
-
([Pull Request](https://github.com/rails/rails/pull/8639))
|
714
|
-
|
715
|
-
* Introduced `validate` as an alias for `valid?`.
|
716
|
-
([Pull Request](https://github.com/rails/rails/pull/14456))
|
717
|
-
|
718
|
-
* `touch` now accepts multiple attributes to be touched at once.
|
719
|
-
([Pull Request](https://github.com/rails/rails/pull/14423))
|
720
|
-
|
721
|
-
* The PostgreSQL adapter now supports the `jsonb` datatype in PostgreSQL 9.4+.
|
722
|
-
([Pull Request](https://github.com/rails/rails/pull/16220))
|
723
|
-
|
724
|
-
* The PostgreSQL and SQLite adapters no longer add a default limit of 255
|
725
|
-
characters on string columns.
|
726
|
-
([Pull Request](https://github.com/rails/rails/pull/14579))
|
727
|
-
|
728
|
-
* Added support for the `citext` column type in the PostgreSQL adapter.
|
729
|
-
([Pull Request](https://github.com/rails/rails/pull/12523))
|
730
|
-
|
731
|
-
* Added support for user-created range types in the PostgreSQL adapter.
|
732
|
-
([Commit](https://github.com/rails/rails/commit/4cb47167e747e8f9dc12b0ddaf82bdb68c03e032))
|
733
|
-
|
734
|
-
* `sqlite3:///some/path` now resolves to the absolute system path
|
735
|
-
`/some/path`. For relative paths, use `sqlite3:some/path` instead.
|
736
|
-
(Previously, `sqlite3:///some/path` resolved to the relative path
|
737
|
-
`some/path`. This behavior was deprecated on Rails 4.1).
|
738
|
-
([Pull Request](https://github.com/rails/rails/pull/14569))
|
739
|
-
|
740
|
-
* Added support for fractional seconds for MySQL 5.6 and above.
|
741
|
-
(Pull Request [1](https://github.com/rails/rails/pull/8240),
|
742
|
-
[2](https://github.com/rails/rails/pull/14359))
|
743
|
-
|
744
|
-
* Added `ActiveRecord::Base#pretty_print` to pretty print models.
|
745
|
-
([Pull Request](https://github.com/rails/rails/pull/15172))
|
746
|
-
|
747
|
-
* `ActiveRecord::Base#reload` now behaves the same as `m = Model.find(m.id)`,
|
748
|
-
meaning that it no longer retains the extra attributes from custom
|
749
|
-
`SELECT`s.
|
750
|
-
([Pull Request](https://github.com/rails/rails/pull/15866))
|
751
|
-
|
752
|
-
* `ActiveRecord::Base#reflections` now returns a hash with string keys instead
|
753
|
-
of symbol keys. ([Pull Request](https://github.com/rails/rails/pull/17718))
|
754
|
-
|
755
|
-
* The `references` method in migrations now supports a `type` option for
|
756
|
-
specifying the type of the foreign key (e.g. `:uuid`).
|
757
|
-
([Pull Request](https://github.com/rails/rails/pull/16231))
|
758
|
-
|
759
|
-
Active Model
|
760
|
-
------------
|
761
|
-
|
762
|
-
Please refer to the [Changelog][active-model] for detailed changes.
|
763
|
-
|
764
|
-
### Removals
|
765
|
-
|
766
|
-
* Removed deprecated `Validator#setup` without replacement.
|
767
|
-
([Pull Request](https://github.com/rails/rails/pull/10716))
|
768
|
-
|
769
|
-
### Deprecations
|
770
|
-
|
771
|
-
* Deprecated `reset_#{attribute}` in favor of `restore_#{attribute}`.
|
772
|
-
([Pull Request](https://github.com/rails/rails/pull/16180))
|
773
|
-
|
774
|
-
* Deprecated `ActiveModel::Dirty#reset_changes` in favor of
|
775
|
-
`clear_changes_information`.
|
776
|
-
([Pull Request](https://github.com/rails/rails/pull/16180))
|
777
|
-
|
778
|
-
### Notable changes
|
779
|
-
|
780
|
-
* Introduced `validate` as an alias for `valid?`.
|
781
|
-
([Pull Request](https://github.com/rails/rails/pull/14456))
|
782
|
-
|
783
|
-
* Introduced the `restore_attributes` method in `ActiveModel::Dirty` to restore
|
784
|
-
the changed (dirty) attributes to their previous values.
|
785
|
-
(Pull Request [1](https://github.com/rails/rails/pull/14861),
|
786
|
-
[2](https://github.com/rails/rails/pull/16180))
|
787
|
-
|
788
|
-
* `has_secure_password` no longer disallows blank passwords (i.e. passwords
|
789
|
-
that contains only spaces) by default.
|
790
|
-
([Pull Request](https://github.com/rails/rails/pull/16412))
|
791
|
-
|
792
|
-
* `has_secure_password` now verifies that the given password is less than 72
|
793
|
-
characters if validations are enabled.
|
794
|
-
([Pull Request](https://github.com/rails/rails/pull/15708))
|
795
|
-
|
796
|
-
Active Support
|
797
|
-
--------------
|
798
|
-
|
799
|
-
Please refer to the [Changelog][active-support] for detailed changes.
|
800
|
-
|
801
|
-
### Removals
|
802
|
-
|
803
|
-
* Removed deprecated `Numeric#ago`, `Numeric#until`, `Numeric#since`,
|
804
|
-
`Numeric#from_now`.
|
805
|
-
([Commit](https://github.com/rails/rails/commit/f1eddea1e3f6faf93581c43651348f48b2b7d8bb))
|
806
|
-
|
807
|
-
* Removed deprecated string based terminators for `ActiveSupport::Callbacks`.
|
808
|
-
([Pull Request](https://github.com/rails/rails/pull/15100))
|
809
|
-
|
810
|
-
### Deprecations
|
811
|
-
|
812
|
-
* Deprecated `Kernel#silence_stderr`, `Kernel#capture` and `Kernel#quietly`
|
813
|
-
without replacement.
|
814
|
-
([Pull Request](https://github.com/rails/rails/pull/13392))
|
815
|
-
|
816
|
-
* Deprecated `Class#superclass_delegating_accessor`, use
|
817
|
-
`Class#class_attribute` instead.
|
818
|
-
([Pull Request](https://github.com/rails/rails/pull/14271))
|
819
|
-
|
820
|
-
* Deprecated `ActiveSupport::SafeBuffer#prepend!` as
|
821
|
-
`ActiveSupport::SafeBuffer#prepend` now performs the same function.
|
822
|
-
([Pull Request](https://github.com/rails/rails/pull/14529))
|
823
|
-
|
824
|
-
### Notable changes
|
825
|
-
|
826
|
-
* Introduced a new configuration option `active_support.test_order` for
|
827
|
-
specifying the order test cases are executed. This option currently defaults
|
828
|
-
to `:sorted` but will be changed to `:random` in Rails 5.0.
|
829
|
-
([Commit](https://github.com/rails/rails/commit/53e877f7d9291b2bf0b8c425f9e32ef35829f35b))
|
830
|
-
|
831
|
-
* `Object#try` and `Object#try!` can now be used without an explicit receiver in the block.
|
832
|
-
([Commit](https://github.com/rails/rails/commit/5e51bdda59c9ba8e5faf86294e3e431bd45f1830),
|
833
|
-
[Pull Request](https://github.com/rails/rails/pull/17361))
|
834
|
-
|
835
|
-
* The `travel_to` test helper now truncates the `usec` component to 0.
|
836
|
-
([Commit](https://github.com/rails/rails/commit/9f6e82ee4783e491c20f5244a613fdeb4024beb5))
|
837
|
-
|
838
|
-
* Introduced `Object#itself` as an identity function.
|
839
|
-
(Commit [1](https://github.com/rails/rails/commit/702ad710b57bef45b081ebf42e6fa70820fdd810),
|
840
|
-
[2](https://github.com/rails/rails/commit/64d91122222c11ad3918cc8e2e3ebc4b0a03448a))
|
841
|
-
|
842
|
-
* `Object#with_options` can now be used without an explicit receiver in the block.
|
843
|
-
([Pull Request](https://github.com/rails/rails/pull/16339))
|
844
|
-
|
845
|
-
* Introduced `String#truncate_words` to truncate a string by a number of words.
|
846
|
-
([Pull Request](https://github.com/rails/rails/pull/16190))
|
847
|
-
|
848
|
-
* Added `Hash#transform_values` and `Hash#transform_values!` to simplify a
|
849
|
-
common pattern where the values of a hash must change, but the keys are left
|
850
|
-
the same.
|
851
|
-
([Pull Request](https://github.com/rails/rails/pull/15819))
|
852
|
-
|
853
|
-
* The `humanize` inflector helper now strips any leading underscores.
|
854
|
-
([Commit](https://github.com/rails/rails/commit/daaa21bc7d20f2e4ff451637423a25ff2d5e75c7))
|
855
|
-
|
856
|
-
* Introduced `Concern#class_methods` as an alternative to
|
857
|
-
`module ClassMethods`, as well as `Kernel#concern` to avoid the
|
858
|
-
`module Foo; extend ActiveSupport::Concern; end` boilerplate.
|
859
|
-
([Commit](https://github.com/rails/rails/commit/b16c36e688970df2f96f793a759365b248b582ad))
|
860
|
-
|
861
|
-
* New [guide](constant_autoloading_and_reloading.html) about constant autoloading and reloading.
|
862
|
-
|
863
|
-
Credits
|
864
|
-
-------
|
865
|
-
|
866
|
-
See the
|
867
|
-
[full list of contributors to Rails](http://contributors.rubyonrails.org/) for
|
868
|
-
the many people who spent many hours making Rails the stable and robust
|
869
|
-
framework it is today. Kudos to all of them.
|
870
|
-
|
871
|
-
[railties]: https://github.com/rails/rails/blob/4-2-stable/railties/CHANGELOG.md
|
872
|
-
[action-pack]: https://github.com/rails/rails/blob/4-2-stable/actionpack/CHANGELOG.md
|
873
|
-
[action-view]: https://github.com/rails/rails/blob/4-2-stable/actionview/CHANGELOG.md
|
874
|
-
[action-mailer]: https://github.com/rails/rails/blob/4-2-stable/actionmailer/CHANGELOG.md
|
875
|
-
[active-record]: https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md
|
876
|
-
[active-model]: https://github.com/rails/rails/blob/4-2-stable/activemodel/CHANGELOG.md
|
877
|
-
[active-support]: https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md
|