rails 4.2.0.beta4 → 4.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/guides/Rakefile +3 -1
- data/guides/bug_report_templates/action_controller_gem.rb +2 -2
- data/guides/bug_report_templates/action_controller_master.rb +2 -2
- data/guides/source/3_0_release_notes.md +2 -2
- data/guides/source/4_1_release_notes.md +1 -1
- data/guides/source/4_2_release_notes.md +250 -225
- data/guides/source/_welcome.html.erb +1 -1
- data/guides/source/action_controller_overview.md +6 -6
- data/guides/source/action_mailer_basics.md +26 -11
- data/guides/source/action_view_overview.md +0 -1
- data/guides/source/active_job_basics.md +29 -23
- data/guides/source/active_record_postgresql.md +2 -7
- data/guides/source/active_record_validations.md +1 -0
- data/guides/source/active_support_core_extensions.md +1 -1
- data/guides/source/active_support_instrumentation.md +5 -5
- data/guides/source/asset_pipeline.md +2 -2
- data/guides/source/association_basics.md +0 -2
- data/guides/source/command_line.md +6 -15
- data/guides/source/configuring.md +4 -4
- data/guides/source/documents.yaml +0 -1
- data/guides/source/engines.md +26 -15
- data/guides/source/form_helpers.md +10 -2
- data/guides/source/getting_started.md +9 -9
- data/guides/source/rails_on_rack.md +2 -2
- data/guides/source/ruby_on_rails_guides_guidelines.md +1 -0
- data/guides/source/security.md +1 -1
- data/guides/source/testing.md +80 -13
- data/guides/source/upgrading_ruby_on_rails.md +23 -20
- metadata +29 -229
- data/guides/output/2_2_release_notes.html +0 -724
- data/guides/output/2_3_release_notes.html +0 -870
- data/guides/output/3_0_release_notes.html +0 -773
- data/guides/output/3_1_release_notes.html +0 -740
- data/guides/output/3_2_release_notes.html +0 -797
- data/guides/output/4_0_release_notes.html +0 -523
- data/guides/output/4_1_release_notes.html +0 -806
- data/guides/output/4_2_release_notes.html +0 -728
- data/guides/output/Gemfile +0 -6
- data/guides/output/_license.html +0 -226
- data/guides/output/_welcome.html +0 -233
- data/guides/output/action_controller_overview.html +0 -1335
- data/guides/output/action_mailer_basics.html +0 -928
- data/guides/output/action_view_overview.html +0 -1509
- data/guides/output/active_job_basics.html +0 -546
- data/guides/output/active_model_basics.html +0 -438
- data/guides/output/active_record_basics.html +0 -594
- data/guides/output/active_record_callbacks.html +0 -592
- data/guides/output/active_record_migrations.html +0 -1123
- data/guides/output/active_record_postgresql.html +0 -675
- data/guides/output/active_record_querying.html +0 -1796
- data/guides/output/active_record_validations.html +0 -1301
- data/guides/output/active_support_core_extensions.html +0 -3450
- data/guides/output/active_support_instrumentation.html +0 -1121
- data/guides/output/api_documentation_guidelines.html +0 -498
- data/guides/output/asset_pipeline.html +0 -1167
- data/guides/output/association_basics.html +0 -2086
- data/guides/output/caching_with_rails.html +0 -553
- data/guides/output/command_line.html +0 -791
- data/guides/output/configuring.html +0 -1055
- data/guides/output/contributing_to_ruby_on_rails.html +0 -657
- data/guides/output/credits.html +0 -284
- data/guides/output/debugging_rails_applications.html +0 -1014
- data/guides/output/development_dependencies_install.html +0 -478
- data/guides/output/engines.html +0 -1438
- data/guides/output/form_helpers.html +0 -1074
- data/guides/output/generators.html +0 -838
- data/guides/output/getting_started.html +0 -2092
- data/guides/output/i18n.html +0 -1198
- data/guides/output/images/akshaysurve.jpg +0 -0
- data/guides/output/images/belongs_to.png +0 -0
- data/guides/output/images/book_icon.gif +0 -0
- data/guides/output/images/bullet.gif +0 -0
- data/guides/output/images/chapters_icon.gif +0 -0
- data/guides/output/images/check_bullet.gif +0 -0
- data/guides/output/images/credits_pic_blank.gif +0 -0
- data/guides/output/images/csrf.png +0 -0
- data/guides/output/images/edge_badge.png +0 -0
- data/guides/output/images/favicon.ico +0 -0
- data/guides/output/images/feature_tile.gif +0 -0
- data/guides/output/images/footer_tile.gif +0 -0
- data/guides/output/images/fxn.png +0 -0
- data/guides/output/images/getting_started/article_with_comments.png +0 -0
- data/guides/output/images/getting_started/challenge.png +0 -0
- data/guides/output/images/getting_started/confirm_dialog.png +0 -0
- data/guides/output/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
- data/guides/output/images/getting_started/forbidden_attributes_for_new_post.png +0 -0
- data/guides/output/images/getting_started/form_with_errors.png +0 -0
- data/guides/output/images/getting_started/index_action_with_edit_link.png +0 -0
- data/guides/output/images/getting_started/new_article.png +0 -0
- data/guides/output/images/getting_started/new_post.png +0 -0
- data/guides/output/images/getting_started/post_with_comments.png +0 -0
- data/guides/output/images/getting_started/rails_welcome.png +0 -0
- data/guides/output/images/getting_started/routing_error_no_controller.png +0 -0
- data/guides/output/images/getting_started/routing_error_no_route_matches.png +0 -0
- data/guides/output/images/getting_started/show_action_for_articles.png +0 -0
- data/guides/output/images/getting_started/show_action_for_posts.png +0 -0
- data/guides/output/images/getting_started/template_is_missing_articles_new.png +0 -0
- data/guides/output/images/getting_started/template_is_missing_posts_new.png +0 -0
- data/guides/output/images/getting_started/undefined_method_post_path.png +0 -0
- data/guides/output/images/getting_started/unknown_action_create_for_articles.png +0 -0
- data/guides/output/images/getting_started/unknown_action_create_for_posts.png +0 -0
- data/guides/output/images/getting_started/unknown_action_new_for_articles.png +0 -0
- data/guides/output/images/getting_started/unknown_action_new_for_posts.png +0 -0
- data/guides/output/images/grey_bullet.gif +0 -0
- data/guides/output/images/habtm.png +0 -0
- data/guides/output/images/has_many.png +0 -0
- data/guides/output/images/has_many_through.png +0 -0
- data/guides/output/images/has_one.png +0 -0
- data/guides/output/images/has_one_through.png +0 -0
- data/guides/output/images/header_backdrop.png +0 -0
- data/guides/output/images/header_tile.gif +0 -0
- data/guides/output/images/i18n/demo_html_safe.png +0 -0
- data/guides/output/images/i18n/demo_localized_pirate.png +0 -0
- data/guides/output/images/i18n/demo_translated_en.png +0 -0
- data/guides/output/images/i18n/demo_translated_pirate.png +0 -0
- data/guides/output/images/i18n/demo_translation_missing.png +0 -0
- data/guides/output/images/i18n/demo_untranslated.png +0 -0
- data/guides/output/images/icons/README +0 -5
- data/guides/output/images/icons/callouts/1.png +0 -0
- data/guides/output/images/icons/callouts/10.png +0 -0
- data/guides/output/images/icons/callouts/11.png +0 -0
- data/guides/output/images/icons/callouts/12.png +0 -0
- data/guides/output/images/icons/callouts/13.png +0 -0
- data/guides/output/images/icons/callouts/14.png +0 -0
- data/guides/output/images/icons/callouts/15.png +0 -0
- data/guides/output/images/icons/callouts/2.png +0 -0
- data/guides/output/images/icons/callouts/3.png +0 -0
- data/guides/output/images/icons/callouts/4.png +0 -0
- data/guides/output/images/icons/callouts/5.png +0 -0
- data/guides/output/images/icons/callouts/6.png +0 -0
- data/guides/output/images/icons/callouts/7.png +0 -0
- data/guides/output/images/icons/callouts/8.png +0 -0
- data/guides/output/images/icons/callouts/9.png +0 -0
- data/guides/output/images/icons/caution.png +0 -0
- data/guides/output/images/icons/example.png +0 -0
- data/guides/output/images/icons/home.png +0 -0
- data/guides/output/images/icons/important.png +0 -0
- data/guides/output/images/icons/next.png +0 -0
- data/guides/output/images/icons/note.png +0 -0
- data/guides/output/images/icons/prev.png +0 -0
- data/guides/output/images/icons/tip.png +0 -0
- data/guides/output/images/icons/up.png +0 -0
- data/guides/output/images/icons/warning.png +0 -0
- data/guides/output/images/nav_arrow.gif +0 -0
- data/guides/output/images/oscardelben.jpg +0 -0
- data/guides/output/images/polymorphic.png +0 -0
- data/guides/output/images/radar.png +0 -0
- data/guides/output/images/rails4_features.png +0 -0
- data/guides/output/images/rails_guides_kindle_cover.jpg +0 -0
- data/guides/output/images/rails_guides_logo.gif +0 -0
- data/guides/output/images/rails_logo_remix.gif +0 -0
- data/guides/output/images/session_fixation.png +0 -0
- data/guides/output/images/tab_grey.gif +0 -0
- data/guides/output/images/tab_info.gif +0 -0
- data/guides/output/images/tab_note.gif +0 -0
- data/guides/output/images/tab_red.gif +0 -0
- data/guides/output/images/tab_yellow.gif +0 -0
- data/guides/output/images/tab_yellow.png +0 -0
- data/guides/output/images/vijaydev.jpg +0 -0
- data/guides/output/index.html +0 -354
- data/guides/output/initialization.html +0 -876
- data/guides/output/javascripts/guides.js +0 -59
- data/guides/output/javascripts/jquery.min.js +0 -4
- data/guides/output/javascripts/responsive-tables.js +0 -43
- data/guides/output/javascripts/syntaxhighlighter/shBrushAS3.js +0 -59
- data/guides/output/javascripts/syntaxhighlighter/shBrushAppleScript.js +0 -75
- data/guides/output/javascripts/syntaxhighlighter/shBrushBash.js +0 -59
- data/guides/output/javascripts/syntaxhighlighter/shBrushCSharp.js +0 -65
- data/guides/output/javascripts/syntaxhighlighter/shBrushColdFusion.js +0 -100
- data/guides/output/javascripts/syntaxhighlighter/shBrushCpp.js +0 -97
- data/guides/output/javascripts/syntaxhighlighter/shBrushCss.js +0 -91
- data/guides/output/javascripts/syntaxhighlighter/shBrushDelphi.js +0 -55
- data/guides/output/javascripts/syntaxhighlighter/shBrushDiff.js +0 -41
- data/guides/output/javascripts/syntaxhighlighter/shBrushErlang.js +0 -52
- data/guides/output/javascripts/syntaxhighlighter/shBrushGroovy.js +0 -67
- data/guides/output/javascripts/syntaxhighlighter/shBrushJScript.js +0 -52
- data/guides/output/javascripts/syntaxhighlighter/shBrushJava.js +0 -57
- data/guides/output/javascripts/syntaxhighlighter/shBrushJavaFX.js +0 -58
- data/guides/output/javascripts/syntaxhighlighter/shBrushPerl.js +0 -72
- data/guides/output/javascripts/syntaxhighlighter/shBrushPhp.js +0 -88
- data/guides/output/javascripts/syntaxhighlighter/shBrushPlain.js +0 -33
- data/guides/output/javascripts/syntaxhighlighter/shBrushPowerShell.js +0 -74
- data/guides/output/javascripts/syntaxhighlighter/shBrushPython.js +0 -64
- data/guides/output/javascripts/syntaxhighlighter/shBrushRuby.js +0 -55
- data/guides/output/javascripts/syntaxhighlighter/shBrushSass.js +0 -94
- data/guides/output/javascripts/syntaxhighlighter/shBrushScala.js +0 -51
- data/guides/output/javascripts/syntaxhighlighter/shBrushSql.js +0 -66
- data/guides/output/javascripts/syntaxhighlighter/shBrushVb.js +0 -56
- data/guides/output/javascripts/syntaxhighlighter/shBrushXml.js +0 -69
- data/guides/output/javascripts/syntaxhighlighter/shCore.js +0 -17
- data/guides/output/layout.html +0 -448
- data/guides/output/layouts_and_rendering.html +0 -1541
- data/guides/output/maintenance_policy.html +0 -257
- data/guides/output/migrations.html +0 -1360
- data/guides/output/nested_model_forms.html +0 -412
- data/guides/output/plugins.html +0 -644
- data/guides/output/rails_application_templates.html +0 -450
- data/guides/output/rails_on_rack.html +0 -547
- data/guides/output/routing.html +0 -1631
- data/guides/output/ruby_on_rails_guides_guidelines.html +0 -329
- data/guides/output/security.html +0 -935
- data/guides/output/stylesheets/fixes.css +0 -16
- data/guides/output/stylesheets/kindle.css +0 -11
- data/guides/output/stylesheets/main.css +0 -713
- data/guides/output/stylesheets/print.css +0 -52
- data/guides/output/stylesheets/reset.css +0 -43
- data/guides/output/stylesheets/responsive-tables.css +0 -50
- data/guides/output/stylesheets/style.css +0 -13
- data/guides/output/stylesheets/syntaxhighlighter/shCore.css +0 -226
- data/guides/output/stylesheets/syntaxhighlighter/shCoreDefault.css +0 -328
- data/guides/output/stylesheets/syntaxhighlighter/shCoreDjango.css +0 -331
- data/guides/output/stylesheets/syntaxhighlighter/shCoreEclipse.css +0 -339
- data/guides/output/stylesheets/syntaxhighlighter/shCoreEmacs.css +0 -324
- data/guides/output/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
- data/guides/output/stylesheets/syntaxhighlighter/shCoreMDUltra.css +0 -324
- data/guides/output/stylesheets/syntaxhighlighter/shCoreMidnight.css +0 -324
- data/guides/output/stylesheets/syntaxhighlighter/shCoreRDark.css +0 -324
- data/guides/output/stylesheets/syntaxhighlighter/shThemeDefault.css +0 -117
- data/guides/output/stylesheets/syntaxhighlighter/shThemeDjango.css +0 -120
- data/guides/output/stylesheets/syntaxhighlighter/shThemeEclipse.css +0 -128
- data/guides/output/stylesheets/syntaxhighlighter/shThemeEmacs.css +0 -113
- data/guides/output/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
- data/guides/output/stylesheets/syntaxhighlighter/shThemeMDUltra.css +0 -113
- data/guides/output/stylesheets/syntaxhighlighter/shThemeMidnight.css +0 -113
- data/guides/output/stylesheets/syntaxhighlighter/shThemeRDark.css +0 -113
- data/guides/output/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +0 -116
- data/guides/output/testing.html +0 -1350
- data/guides/output/upgrading_ruby_on_rails.html +0 -1135
- data/guides/output/working_with_javascript_in_rails.html +0 -587
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a94a420de40f59147615336adb6378560cc5f90c
|
4
|
+
data.tar.gz: c36d15873cf2e140bc1c7f515d203562b1922d7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01dacbef8f0f4bb36e58c13c0d8d4eb4a1abd6041124fdbab4c0b0de700dc153ba891591e1c38fe9b768500d783cc34df6f6250f4b5627395ab298e7d3b94d19
|
7
|
+
data.tar.gz: 223e7933d3974f10597125066d69e5b8f9b0ce942ab54ae79bb98cfb1bf2fc3cd2892818e0d911ad2c6a7af1f70b5c8e5b8cab5c71e0f13e82ad178dc30fa225
|
data/guides/Rakefile
CHANGED
@@ -34,10 +34,12 @@ namespace :guides do
|
|
34
34
|
task :help do
|
35
35
|
puts <<-help
|
36
36
|
|
37
|
-
Guides are taken from the source directory, and the
|
37
|
+
Guides are taken from the source directory, and the result goes into the
|
38
38
|
output directory. Assets are stored under files, and copied to output/files as
|
39
39
|
part of the generation process.
|
40
40
|
|
41
|
+
You can generate HTML, Kindle or both formats using the `guides:generate` task.
|
42
|
+
|
41
43
|
All this process is handled via rake tasks, here's a full list of them:
|
42
44
|
|
43
45
|
#{%x[rake -T]}
|
@@ -7,8 +7,8 @@ require 'action_controller/railtie'
|
|
7
7
|
class TestApp < Rails::Application
|
8
8
|
config.root = File.dirname(__FILE__)
|
9
9
|
config.session_store :cookie_store, key: 'cookie_store_key'
|
10
|
-
|
11
|
-
|
10
|
+
secrets.secret_token = 'secret_token'
|
11
|
+
secrets.secret_key_base = 'secret_key_base'
|
12
12
|
|
13
13
|
config.logger = Logger.new($stdout)
|
14
14
|
Rails.logger = config.logger
|
@@ -19,8 +19,8 @@ require 'action_controller/railtie'
|
|
19
19
|
class TestApp < Rails::Application
|
20
20
|
config.root = File.dirname(__FILE__)
|
21
21
|
config.session_store :cookie_store, key: 'cookie_store_key'
|
22
|
-
|
23
|
-
|
22
|
+
secrets.secret_token = 'secret_token'
|
23
|
+
secrets.secret_key_base = 'secret_key_base'
|
24
24
|
|
25
25
|
config.logger = Logger.new($stdout)
|
26
26
|
Rails.logger = config.logger
|
@@ -138,7 +138,7 @@ More Information: - [Rails Edge Architecture](http://yehudakatz.com/2009/06/11/r
|
|
138
138
|
|
139
139
|
[Arel](http://github.com/brynary/arel) (or Active Relation) has been taken on as the underpinnings of Active Record and is now required for Rails. Arel provides an SQL abstraction that simplifies out Active Record and provides the underpinnings for the relation functionality in Active Record.
|
140
140
|
|
141
|
-
More information: - [Why I wrote Arel](http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel
|
141
|
+
More information: - [Why I wrote Arel](https://web.archive.org/web/20120718093140/http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/)
|
142
142
|
|
143
143
|
|
144
144
|
### Mail Extraction
|
@@ -298,7 +298,7 @@ Deprecations
|
|
298
298
|
|
299
299
|
More Information:
|
300
300
|
* [The Rails 3 Router: Rack it Up](http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/)
|
301
|
-
* [Revamped Routes in Rails 3](
|
301
|
+
* [Revamped Routes in Rails 3](https://medium.com/fusion-of-thoughts/revamped-routes-in-rails-3-b6d00654e5b0)
|
302
302
|
* [Generic Actions in Rails 3](http://yehudakatz.com/2009/12/20/generic-actions-in-rails-3/)
|
303
303
|
|
304
304
|
|
@@ -136,7 +136,7 @@ end
|
|
136
136
|
|
137
137
|
### Action Mailer Previews
|
138
138
|
|
139
|
-
Action Mailer previews provide a way to
|
139
|
+
Action Mailer previews provide a way to see how emails look by visiting
|
140
140
|
a special URL that renders them.
|
141
141
|
|
142
142
|
You implement a preview class whose methods return the mail object you'd like
|
@@ -3,21 +3,19 @@ Ruby on Rails 4.2 Release Notes
|
|
3
3
|
|
4
4
|
Highlights in Rails 4.2:
|
5
5
|
|
6
|
-
* Active Job
|
6
|
+
* Active Job
|
7
|
+
* Asynchronous mails
|
7
8
|
* Adequate Record
|
8
9
|
* Web Console
|
9
10
|
* Foreign key support
|
10
11
|
|
11
|
-
These release notes cover only the major changes. To learn about
|
12
|
-
fixes and changes, please refer to the
|
13
|
-
commits](https://github.com/rails/rails/commits/
|
14
|
-
repository on GitHub.
|
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.
|
15
16
|
|
16
17
|
--------------------------------------------------------------------------------
|
17
18
|
|
18
|
-
NOTE: This document is a work in progress, please help to improve this by sending
|
19
|
-
a [pull request](https://github.com/rails/rails/edit/master/guides/source/4_2_release_notes.md).
|
20
|
-
|
21
19
|
Upgrading to Rails 4.2
|
22
20
|
----------------------
|
23
21
|
|
@@ -25,96 +23,112 @@ If you're upgrading an existing application, it's a great idea to have good test
|
|
25
23
|
coverage before going in. You should also first upgrade to Rails 4.1 in case you
|
26
24
|
haven't and make sure your application still runs as expected before attempting
|
27
25
|
to upgrade to Rails 4.2. A list of things to watch out for when upgrading is
|
28
|
-
available in the guide
|
29
|
-
Rails](upgrading_ruby_on_rails.html#upgrading-from-rails-4-1-to-rails-4-2)
|
26
|
+
available in the guide [Upgrading Ruby on
|
27
|
+
Rails](upgrading_ruby_on_rails.html#upgrading-from-rails-4-1-to-rails-4-2).
|
30
28
|
|
31
29
|
|
32
30
|
Major Features
|
33
31
|
--------------
|
34
32
|
|
35
|
-
### Active Job
|
33
|
+
### Active Job
|
36
34
|
|
37
|
-
Active Job is a new framework in Rails 4.2. It is
|
35
|
+
Active Job is a new framework in Rails 4.2. It is a common interface on top of
|
38
36
|
queuing systems like [Resque](https://github.com/resque/resque), [Delayed
|
39
37
|
Job](https://github.com/collectiveidea/delayed_job),
|
40
38
|
[Sidekiq](https://github.com/mperham/sidekiq), and more.
|
41
39
|
|
42
|
-
|
43
|
-
|
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.
|
44
49
|
|
45
|
-
|
46
|
-
|
47
|
-
bog down the controller or model.
|
50
|
+
For example, if `trashable` is an Active Record object, then this job runs
|
51
|
+
just fine with no serialization involved:
|
48
52
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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`.
|
54
71
|
|
55
72
|
### Adequate Record
|
56
73
|
|
57
|
-
Adequate Record is a set of
|
58
|
-
`find_by`
|
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.
|
59
76
|
|
60
|
-
It works by caching SQL
|
61
|
-
|
62
|
-
|
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
|
63
80
|
post](http://tenderlovemaking.com/2014/02/19/adequaterecord-pro-like-activerecord.html).
|
64
81
|
|
65
|
-
|
66
|
-
|
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:
|
67
85
|
|
68
86
|
```ruby
|
69
|
-
Post.find
|
70
|
-
Post.find
|
87
|
+
Post.find(1) # First call generates and cache the prepared statement
|
88
|
+
Post.find(2) # Subsequent calls reuse the cached prepared statement
|
71
89
|
|
72
|
-
Post.find_by_title
|
73
|
-
Post.find_by_title
|
90
|
+
Post.find_by_title('first post')
|
91
|
+
Post.find_by_title('second post')
|
74
92
|
|
75
|
-
post.comments
|
76
|
-
post.comments(true)
|
93
|
+
post.comments
|
94
|
+
post.comments(true)
|
77
95
|
```
|
78
96
|
|
79
|
-
|
97
|
+
It's important to highlight that, as the examples above suggest, the prepared
|
98
|
+
statements do not cache the values passed in the method calls; rather, they
|
99
|
+
have placeholders for them.
|
100
|
+
|
101
|
+
Caching is not used in the following scenarios:
|
80
102
|
|
81
103
|
- The model has a default scope
|
82
|
-
- The model uses single table inheritance
|
83
|
-
- `find` with a list of ids.
|
104
|
+
- The model uses single table inheritance
|
105
|
+
- `find` with a list of ids, e.g.:
|
84
106
|
|
85
107
|
```ruby
|
86
|
-
|
87
|
-
|
88
|
-
Post.find
|
108
|
+
# not cached
|
109
|
+
Post.find(1, 2, 3)
|
110
|
+
Post.find([1,2])
|
89
111
|
```
|
90
112
|
|
91
|
-
- `find_by` with
|
113
|
+
- `find_by` with SQL fragments:
|
92
114
|
|
93
115
|
```ruby
|
94
|
-
Post.find_by
|
116
|
+
Post.find_by('published_at < ?', 2.weeks.ago)
|
95
117
|
```
|
96
118
|
|
97
119
|
### Web Console
|
98
120
|
|
99
|
-
New applications generated
|
100
|
-
default.
|
121
|
+
New applications generated with Rails 4.2 now come with the [Web
|
122
|
+
Console](https://github.com/rails/web-console) gem by default. Web Console adds
|
123
|
+
an interactive Ruby console on every error page and provides a `console` view
|
124
|
+
and controller helpers.
|
101
125
|
|
102
|
-
|
103
|
-
|
104
|
-
|
126
|
+
The interactive console on error pages lets you execute code in the context of
|
127
|
+
the place where the exception originated. The `console` helper, if called
|
128
|
+
anywhere in a view or controller, launches an interactive console with the final
|
129
|
+
context, once rendering has completed.
|
105
130
|
|
106
|
-
|
107
|
-
exception originated. It's quite handy to introspect the state that led to the
|
108
|
-
error.
|
109
|
-
|
110
|
-
The `console` view helper launches an interactive console within the context of
|
111
|
-
the view where it is invoked.
|
112
|
-
|
113
|
-
Finally, you can launch a VT100 terminal that runs `rails console`. If you need
|
114
|
-
to create or modify existing test data, you can do that straight from the
|
115
|
-
browser.
|
116
|
-
|
117
|
-
### Foreign key support
|
131
|
+
### Foreign Key Support
|
118
132
|
|
119
133
|
The migration DSL now supports adding and removing foreign keys. They are dumped
|
120
134
|
to `schema.rb` as well. At this time, only the `mysql`, `mysql2` and `postgresql`
|
@@ -149,18 +163,18 @@ individual components for new deprecations in this release.
|
|
149
163
|
|
150
164
|
The following changes may require immediate action upon upgrade.
|
151
165
|
|
152
|
-
### `render` with a String
|
166
|
+
### `render` with a String Argument
|
153
167
|
|
154
|
-
Previously, calling `render "foo/bar"` in a controller action
|
155
|
-
`render file: "foo/bar"`. In Rails 4.2, this has been changed to mean
|
156
|
-
instead. If you need to render a file, please
|
157
|
-
explicit form (`render file: "foo/bar"`) instead.
|
168
|
+
Previously, calling `render "foo/bar"` in a controller action was equivalent to
|
169
|
+
`render file: "foo/bar"`. In Rails 4.2, this has been changed to mean
|
170
|
+
`render template: "foo/bar"` instead. If you need to render a file, please
|
171
|
+
change your code to use the explicit form (`render file: "foo/bar"`) instead.
|
158
172
|
|
159
|
-
### `respond_with` /
|
173
|
+
### `respond_with` / Class-Level `respond_to`
|
160
174
|
|
161
|
-
`respond_with` and the corresponding class-level `respond_to` have been moved
|
162
|
-
the
|
163
|
-
your Gemfile:
|
175
|
+
`respond_with` and the corresponding class-level `respond_to` have been moved
|
176
|
+
to the [responders](https://github.com/plataformatec/responders) gem. Add
|
177
|
+
`gem 'responders', '~> 2.0'` to your Gemfile to use it:
|
164
178
|
|
165
179
|
```ruby
|
166
180
|
# app/controllers/users_controller.rb
|
@@ -191,61 +205,47 @@ class UsersController < ApplicationController
|
|
191
205
|
end
|
192
206
|
```
|
193
207
|
|
194
|
-
### Default
|
208
|
+
### Default Host for `rails server`
|
195
209
|
|
196
210
|
Due to a [change in Rack](https://github.com/rack/rack/commit/28b014484a8ac0bbb388e7eaeeef159598ec64fc),
|
197
211
|
`rails server` now listens on `localhost` instead of `0.0.0.0` by default. This
|
198
|
-
should have minimal impact on the standard development workflow as both
|
199
|
-
and http://localhost:3000
|
212
|
+
should have minimal impact on the standard development workflow as both
|
213
|
+
http://127.0.0.1:3000 and http://localhost:3000 will continue to work as before
|
214
|
+
on your own machine.
|
200
215
|
|
201
|
-
However, with this change you
|
202
|
-
from a different machine
|
203
|
-
machine and you would like to access it from the host machine
|
204
|
-
|
216
|
+
However, with this change you will no longer be able to access the Rails
|
217
|
+
server from a different machine, for example if your development environment
|
218
|
+
is in a virtual machine and you would like to access it from the host machine.
|
219
|
+
In such cases, please start the server with `rails server -b 0.0.0.0` to
|
220
|
+
restore the old behavior.
|
205
221
|
|
206
222
|
If you do this, be sure to configure your firewall properly such that only
|
207
223
|
trusted machines on your network can access your development server.
|
208
224
|
|
209
|
-
### Production logging
|
210
|
-
|
211
|
-
The default log level in the `production` environment is now `:debug`. This
|
212
|
-
makes it consistent with the other environments, and ensures plenty of
|
213
|
-
information is available to diagnose problems.
|
214
|
-
|
215
|
-
It can be returned to the previous level, `:info`, in the environment
|
216
|
-
configuration:
|
217
|
-
|
218
|
-
```ruby
|
219
|
-
# config/environments/production.rb
|
220
|
-
|
221
|
-
# Decrease the log volume.
|
222
|
-
config.log_level = :info
|
223
|
-
```
|
224
|
-
|
225
225
|
### HTML Sanitizer
|
226
226
|
|
227
227
|
The HTML sanitizer has been replaced with a new, more robust, implementation
|
228
|
-
built upon Loofah
|
229
|
-
|
228
|
+
built upon [Loofah](https://github.com/flavorjones/loofah) and
|
229
|
+
[Nokogiri](https://github.com/sparklemotion/nokogiri). The new sanitizer is
|
230
|
+
more secure and its sanitization is more powerful and flexible.
|
230
231
|
|
231
|
-
|
232
|
+
Due to the new algorithm, the sanitized output may be different for certain
|
232
233
|
pathological inputs.
|
233
234
|
|
234
|
-
If you have particular need for the exact output of the old sanitizer, you
|
235
|
-
add
|
236
|
-
|
237
|
-
|
235
|
+
If you have a particular need for the exact output of the old sanitizer, you
|
236
|
+
can add the [rails-deprecated_sanitizer](https://github.com/kaspth/rails-deprecated_sanitizer)
|
237
|
+
gem to the `Gemfile`, to have the old behavior. The gem does not issue
|
238
|
+
deprecation warnings because it is opt-in.
|
238
239
|
|
239
240
|
`rails-deprecated_sanitizer` will be supported for Rails 4.2 only; it will not
|
240
241
|
be maintained for Rails 5.0.
|
241
242
|
|
242
|
-
See [
|
243
|
-
for more
|
243
|
+
See [this blog post](http://blog.plataformatec.com.br/2014/07/the-new-html-sanitizer-in-rails-4-2/)
|
244
|
+
for more details on the changes in the new sanitizer.
|
244
245
|
|
245
246
|
### `assert_select`
|
246
247
|
|
247
|
-
`assert_select` is now based on Nokogiri
|
248
|
-
|
248
|
+
`assert_select` is now based on [Nokogiri](https://github.com/sparklemotion/nokogiri).
|
249
249
|
As a result, some previously-valid selectors are now unsupported. If your
|
250
250
|
application is using any of these spellings, you will need to update them:
|
251
251
|
|
@@ -253,8 +253,13 @@ application is using any of these spellings, you will need to update them:
|
|
253
253
|
non-alphanumeric characters.
|
254
254
|
|
255
255
|
```
|
256
|
-
|
257
|
-
a[href
|
256
|
+
# before
|
257
|
+
a[href=/]
|
258
|
+
a[href$=/]
|
259
|
+
|
260
|
+
# now
|
261
|
+
a[href="/"]
|
262
|
+
a[href$="/"]
|
258
263
|
```
|
259
264
|
|
260
265
|
* DOMs built from HTML source containing invalid HTML with improperly
|
@@ -300,11 +305,24 @@ Please refer to the [Changelog][railties] for detailed changes.
|
|
300
305
|
|
301
306
|
### Removals
|
302
307
|
|
308
|
+
* The `--skip-action-view` option has been removed from the
|
309
|
+
app generator. ([Pull Request](https://github.com/rails/rails/pull/17042))
|
310
|
+
|
303
311
|
* The `rails application` command has been removed without replacement.
|
304
312
|
([Pull Request](https://github.com/rails/rails/pull/11616))
|
305
313
|
|
306
314
|
### Deprecations
|
307
315
|
|
316
|
+
* Deprecated missing `config.log_level` for production environments.
|
317
|
+
([Pull Request](https://github.com/rails/rails/pull/16622))
|
318
|
+
|
319
|
+
* Deprecated `rake test:all` in favor of `rake test` as it now run all tests
|
320
|
+
in the `test` folder.
|
321
|
+
([Pull Request](https://github.com/rails/rails/pull/17348))
|
322
|
+
|
323
|
+
* Deprecated `rake test:all:db` in favor of `rake test:db`.
|
324
|
+
([Pull Request](https://github.com/rails/rails/pull/17348))
|
325
|
+
|
308
326
|
* Deprecated `Rails::Rack::LogTailer` without replacement.
|
309
327
|
([Commit](https://github.com/rails/rails/commit/84a13e019e93efaa8994b3f8303d635a7702dbce))
|
310
328
|
|
@@ -316,9 +334,6 @@ Please refer to the [Changelog][railties] for detailed changes.
|
|
316
334
|
* Added a `required` option to the model generator for associations.
|
317
335
|
([Pull Request](https://github.com/rails/rails/pull/16062))
|
318
336
|
|
319
|
-
* Introduced an `after_bundle` callback for use in Rails templates.
|
320
|
-
([Pull Request](https://github.com/rails/rails/pull/16359))
|
321
|
-
|
322
337
|
* Introduced the `x` namespace for defining custom configuration options:
|
323
338
|
|
324
339
|
```ruby
|
@@ -358,20 +373,23 @@ Please refer to the [Changelog][railties] for detailed changes.
|
|
358
373
|
|
359
374
|
([Pull Request](https://github.com/rails/rails/pull/16129))
|
360
375
|
|
361
|
-
* Introduced a `--skip-
|
362
|
-
|
363
|
-
([Commit](https://github.com/rails/rails/commit/
|
376
|
+
* Introduced a `--skip-turbolinks` option in the app generator to not generate
|
377
|
+
turbolinks integration.
|
378
|
+
([Commit](https://github.com/rails/rails/commit/bf17c8a531bc8059d50ad731398002a3e7162a7d))
|
364
379
|
|
365
|
-
* Introduced a `bin/setup` script
|
380
|
+
* Introduced a `bin/setup` script as a convention for automated setup code when
|
366
381
|
bootstrapping an application.
|
367
382
|
([Pull Request](https://github.com/rails/rails/pull/15189))
|
368
383
|
|
369
|
-
* Changed default value for `config.assets.digest` to `true` in development.
|
384
|
+
* Changed the default value for `config.assets.digest` to `true` in development.
|
370
385
|
([Pull Request](https://github.com/rails/rails/pull/15155))
|
371
386
|
|
372
387
|
* Introduced an API to register new extensions for `rake notes`.
|
373
388
|
([Pull Request](https://github.com/rails/rails/pull/14379))
|
374
389
|
|
390
|
+
* Introduced an `after_bundle` callback for use in Rails templates.
|
391
|
+
([Pull Request](https://github.com/rails/rails/pull/16359))
|
392
|
+
|
375
393
|
* Introduced `Rails.gem_version` as a convenience method to return
|
376
394
|
`Gem::Version.new(Rails.version)`.
|
377
395
|
([Pull Request](https://github.com/rails/rails/pull/14101))
|
@@ -384,10 +402,11 @@ Please refer to the [Changelog][action-pack] for detailed changes.
|
|
384
402
|
|
385
403
|
### Removals
|
386
404
|
|
387
|
-
* `respond_with` and the class-level `respond_to`
|
405
|
+
* `respond_with` and the class-level `respond_to` have been removed from Rails and
|
388
406
|
moved to the `responders` gem (version 2.0). Add `gem 'responders', '~> 2.0'`
|
389
407
|
to your `Gemfile` to continue using these features.
|
390
|
-
([Pull Request](https://github.com/rails/rails/pull/16526)
|
408
|
+
([Pull Request](https://github.com/rails/rails/pull/16526),
|
409
|
+
[More Details](http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#responders))
|
391
410
|
|
392
411
|
* Removed deprecated `AbstractController::Helpers::ClassMethods::MissingHelperError`
|
393
412
|
in favor of `AbstractController::Helpers::MissingHelperError`.
|
@@ -403,7 +422,7 @@ Please refer to the [Changelog][action-pack] for detailed changes.
|
|
403
422
|
([Commit](https://github.com/rails/rails-dom-testing/commit/b12850bc5ff23ba4b599bf2770874dd4f11bf750))
|
404
423
|
|
405
424
|
* Deprecated support for setting the `:to` option of a router to a symbol or a
|
406
|
-
string that does not contain a
|
425
|
+
string that does not contain a "#" character:
|
407
426
|
|
408
427
|
```ruby
|
409
428
|
get '/posts', to: MyRackApp => (No change necessary)
|
@@ -414,22 +433,22 @@ Please refer to the [Changelog][action-pack] for detailed changes.
|
|
414
433
|
|
415
434
|
([Commit](https://github.com/rails/rails/commit/cc26b6b7bccf0eea2e2c1a9ebdcc9d30ca7390d9))
|
416
435
|
|
417
|
-
|
436
|
+
* Deprecated support for string keys in URL helpers:
|
418
437
|
|
419
|
-
|
420
|
-
|
438
|
+
```ruby
|
439
|
+
# bad
|
440
|
+
root_path('controller' => 'posts', 'action' => 'index')
|
421
441
|
|
422
|
-
|
423
|
-
|
424
|
-
|
442
|
+
# good
|
443
|
+
root_path(controller: 'posts', action: 'index')
|
444
|
+
```
|
425
445
|
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
([Pull Request](https://github.com/rails/rails/pull/15933))
|
446
|
+
([Pull Request](https://github.com/rails/rails/pull/17743))
|
447
|
+
|
448
|
+
### Notable changes
|
430
449
|
|
431
|
-
* The `*_filter` family methods have been removed from the documentation. Their
|
432
|
-
usage is discouraged in favor of the `*_action` family methods:
|
450
|
+
* The `*_filter` family of methods have been removed from the documentation. Their
|
451
|
+
usage is discouraged in favor of the `*_action` family of methods:
|
433
452
|
|
434
453
|
```
|
435
454
|
after_filter => after_action
|
@@ -454,16 +473,28 @@ Please refer to the [Changelog][action-pack] for detailed changes.
|
|
454
473
|
(Commit [1](https://github.com/rails/rails/commit/6c5f43bab8206747a8591435b2aa0ff7051ad3de),
|
455
474
|
[2](https://github.com/rails/rails/commit/489a8f2a44dc9cea09154ee1ee2557d1f037c7d4))
|
456
475
|
|
457
|
-
*
|
476
|
+
* `render nothing: true` or rendering a `nil` body no longer add a single
|
477
|
+
space padding to the response body.
|
478
|
+
([Pull Request](https://github.com/rails/rails/pull/14883))
|
479
|
+
|
480
|
+
* Rails now automatically includes the template's digest in ETags.
|
481
|
+
([Pull Request](https://github.com/rails/rails/pull/16527))
|
482
|
+
|
483
|
+
* Segments that are passed into URL helpers are now automatically escaped.
|
484
|
+
([Commit](https://github.com/rails/rails/commit/5460591f0226a9d248b7b4f89186bd5553e7768f))
|
485
|
+
|
486
|
+
* Introduced the `always_permitted_parameters` option to configure which
|
487
|
+
parameters are permitted globally. The default value of this configuration
|
488
|
+
is `['controller', 'action']`.
|
489
|
+
([Pull Request](https://github.com/rails/rails/pull/15933))
|
490
|
+
|
491
|
+
* Added the HTTP method `MKCALENDAR` from [RFC 4791](https://tools.ietf.org/html/rfc4791).
|
458
492
|
([Pull Request](https://github.com/rails/rails/pull/15121))
|
459
493
|
|
460
494
|
* `*_fragment.action_controller` notifications now include the controller
|
461
495
|
and action name in the payload.
|
462
496
|
([Pull Request](https://github.com/rails/rails/pull/14137))
|
463
497
|
|
464
|
-
* Segments that are passed into URL helpers are now automatically escaped.
|
465
|
-
([Commit](https://github.com/rails/rails/commit/5460591f0226a9d248b7b4f89186bd5553e7768f))
|
466
|
-
|
467
498
|
* Improved the Routing Error page with fuzzy matching for route search.
|
468
499
|
([Pull Request](https://github.com/rails/rails/pull/14619))
|
469
500
|
|
@@ -471,28 +502,15 @@ Please refer to the [Changelog][action-pack] for detailed changes.
|
|
471
502
|
([Pull Request](https://github.com/rails/rails/pull/14280))
|
472
503
|
|
473
504
|
* When the Rails server is set to serve static assets, gzip assets will now be
|
474
|
-
served if the client supports it and a pre-generated gzip file (
|
505
|
+
served if the client supports it and a pre-generated gzip file (`.gz`) is on disk.
|
475
506
|
By default the asset pipeline generates `.gz` files for all compressible assets.
|
476
507
|
Serving gzip files minimizes data transfer and speeds up asset requests. Always
|
477
508
|
[use a CDN](http://guides.rubyonrails.org/asset_pipeline.html#cdns) if you are
|
478
509
|
serving assets from your Rails server in production.
|
479
510
|
([Pull Request](https://github.com/rails/rails/pull/16466))
|
480
511
|
|
481
|
-
* The way `assert_select` works has changed; specifically a different library
|
482
|
-
is used to interpret css selectors, build the transient DOM that the
|
483
|
-
selectors are applied against, and to extract the data from that DOM. These
|
484
|
-
changes should only affect edge cases. Examples:
|
485
|
-
* Values in attribute selectors may need to be quoted if they contain
|
486
|
-
non-alphanumeric characters.
|
487
|
-
* DOMs built from HTML source containing invalid HTML with improperly
|
488
|
-
nested elements may differ.
|
489
|
-
* If the data selected contains entities, the value selected for comparison
|
490
|
-
used to be raw (e.g. `AT&T`), and now is evaluated
|
491
|
-
(e.g. `AT&T`).
|
492
|
-
|
493
|
-
|
494
512
|
Action View
|
495
|
-
|
513
|
+
-----------
|
496
514
|
|
497
515
|
Please refer to the [Changelog][action-view] for detailed changes.
|
498
516
|
|
@@ -513,16 +531,16 @@ Please refer to the [Changelog][action-view] for detailed changes.
|
|
513
531
|
`render file: "foo/bar"`.
|
514
532
|
([Pull Request](https://github.com/rails/rails/pull/16888))
|
515
533
|
|
516
|
-
* Introduced a `#{partial_name}_iteration` special local variable for use with
|
517
|
-
partials that are rendered with a collection. It provides access to the
|
518
|
-
current state of the iteration via the `#index`, `#size`, `#first?` and
|
519
|
-
`#last?` methods.
|
520
|
-
([Pull Request](https://github.com/rails/rails/pull/7698))
|
521
|
-
|
522
534
|
* The form helpers no longer generate a `<div>` element with inline CSS around
|
523
535
|
the hidden fields.
|
524
536
|
([Pull Request](https://github.com/rails/rails/pull/14738))
|
525
537
|
|
538
|
+
* Introduced a `#{partial_name}_iteration` special local variable for use with
|
539
|
+
partials that are rendered with a collection. It provides access to the
|
540
|
+
current state of the iteration via the `index`, `size`, `first?` and
|
541
|
+
`last?` methods.
|
542
|
+
([Pull Request](https://github.com/rails/rails/pull/7698))
|
543
|
+
|
526
544
|
* Placeholder I18n follows the same convention as `label` I18n.
|
527
545
|
([Pull Request](https://github.com/rails/rails/pull/16438))
|
528
546
|
|
@@ -537,11 +555,15 @@ Please refer to the [Changelog][action-mailer] for detailed changes.
|
|
537
555
|
* Deprecated `*_path` helpers in mailers. Always use `*_url` helpers instead.
|
538
556
|
([Pull Request](https://github.com/rails/rails/pull/15840))
|
539
557
|
|
540
|
-
* Deprecated `deliver` / `deliver!` in
|
558
|
+
* Deprecated `deliver` / `deliver!` in favor of `deliver_now` / `deliver_now!`.
|
541
559
|
([Pull Request](https://github.com/rails/rails/pull/16582))
|
542
560
|
|
543
561
|
### Notable changes
|
544
562
|
|
563
|
+
* `link_to` and `url_for` generate absolute URLs by default in templates,
|
564
|
+
it is no longer needed to pass `only_path: false`.
|
565
|
+
([Commit](https://github.com/rails/rails/commit/9685080a7677abfa5d288a81c3e078368c6bb67c))
|
566
|
+
|
545
567
|
* Introduced `deliver_later` which enqueues a job on the application's queue
|
546
568
|
to deliver emails asynchronously.
|
547
569
|
([Pull Request](https://github.com/rails/rails/pull/16485))
|
@@ -570,7 +592,7 @@ Please refer to the [Changelog][active-record] for detailed changes.
|
|
570
592
|
|
571
593
|
* Removed unused `:timestamp` type. Transparently alias it to `:datetime`
|
572
594
|
in all cases. Fixes inconsistencies when column types are sent outside of
|
573
|
-
|
595
|
+
Active Record, such as for XML serialization.
|
574
596
|
([Pull Request](https://github.com/rails/rails/pull/15184))
|
575
597
|
|
576
598
|
### Deprecations
|
@@ -578,112 +600,116 @@ Please refer to the [Changelog][active-record] for detailed changes.
|
|
578
600
|
* Deprecated swallowing of errors inside `after_commit` and `after_rollback`.
|
579
601
|
([Pull Request](https://github.com/rails/rails/pull/16537))
|
580
602
|
|
581
|
-
* Deprecated calling `DatabaseTasks.load_schema` without a connection. Use
|
582
|
-
`DatabaseTasks.load_schema_current` instead.
|
583
|
-
([Commit](https://github.com/rails/rails/commit/f15cef67f75e4b52fd45655d7c6ab6b35623c608))
|
584
|
-
|
585
|
-
* Deprecated `Reflection#source_macro` without replacement as it is no longer
|
586
|
-
needed in Active Record.
|
587
|
-
([Pull Request](https://github.com/rails/rails/pull/16373))
|
588
|
-
|
589
603
|
* Deprecated broken support for automatic detection of counter caches on
|
590
604
|
`has_many :through` associations. You should instead manually specify the
|
591
605
|
counter cache on the `has_many` and `belongs_to` associations for the
|
592
606
|
through records.
|
593
607
|
([Pull Request](https://github.com/rails/rails/pull/15754))
|
594
608
|
|
595
|
-
* Deprecated `serialized_attributes` without replacement.
|
596
|
-
([Pull Request](https://github.com/rails/rails/pull/15704))
|
597
|
-
|
598
|
-
* Deprecated returning `nil` from `column_for_attribute` when no column
|
599
|
-
exists. It will return a null object in Rails 5.0
|
600
|
-
([Pull Request](https://github.com/rails/rails/pull/15878))
|
601
|
-
|
602
|
-
* Deprecated using `.joins`, `.preload` and `.eager_load` with associations
|
603
|
-
that depends on the instance state (i.e. those defined with a scope that
|
604
|
-
takes an argument) without replacement.
|
605
|
-
([Commit](https://github.com/rails/rails/commit/ed56e596a0467390011bc9d56d462539776adac1))
|
606
|
-
|
607
609
|
* Deprecated passing Active Record objects to `.find` or `.exists?`. Call
|
608
|
-
|
610
|
+
`id` on the objects first.
|
609
611
|
(Commit [1](https://github.com/rails/rails/commit/d92ae6ccca3bcfd73546d612efaea011270bd270),
|
610
612
|
[2](https://github.com/rails/rails/commit/d35f0033c7dec2b8d8b52058fb8db495d49596f7))
|
611
613
|
|
612
614
|
* Deprecated half-baked support for PostgreSQL range values with excluding
|
613
615
|
beginnings. We currently map PostgreSQL ranges to Ruby ranges. This conversion
|
614
|
-
is not fully possible because
|
615
|
-
beginnings.
|
616
|
+
is not fully possible because Ruby ranges do not support excluded beginnings.
|
616
617
|
|
617
618
|
The current solution of incrementing the beginning is not correct
|
618
619
|
and is now deprecated. For subtypes where we don't know how to increment
|
619
|
-
(e.g.
|
620
|
+
(e.g. `succ` is not defined) it will raise an `ArgumentError` for ranges
|
620
621
|
with excluding beginnings.
|
621
|
-
|
622
622
|
([Commit](https://github.com/rails/rails/commit/91949e48cf41af9f3e4ffba3e5eecf9b0a08bfc3))
|
623
623
|
|
624
|
-
|
624
|
+
* Deprecated calling `DatabaseTasks.load_schema` without a connection. Use
|
625
|
+
`DatabaseTasks.load_schema_current` instead.
|
626
|
+
([Commit](https://github.com/rails/rails/commit/f15cef67f75e4b52fd45655d7c6ab6b35623c608))
|
625
627
|
|
626
|
-
*
|
627
|
-
|
628
|
+
* Deprecated `sanitize_sql_hash_for_conditions` without replacement. Using a
|
629
|
+
`Relation` for performing queries and updates is the preferred API.
|
630
|
+
([Commit](https://github.com/rails/rails/commit/d5902c9e))
|
628
631
|
|
629
|
-
*
|
630
|
-
|
631
|
-
([Pull Request](https://github.com/rails/rails/pull/
|
632
|
+
* Deprecated `Reflection#source_macro` without replacement as it is no longer
|
633
|
+
needed in Active Record.
|
634
|
+
([Pull Request](https://github.com/rails/rails/pull/16373))
|
632
635
|
|
633
|
-
*
|
634
|
-
|
635
|
-
([Pull Request](https://github.com/rails/rails/pull/16056))
|
636
|
+
* Deprecated `serialized_attributes` without replacement.
|
637
|
+
([Pull Request](https://github.com/rails/rails/pull/15704))
|
636
638
|
|
637
|
-
*
|
638
|
-
|
639
|
-
([Pull Request](https://github.com/rails/rails/pull/
|
639
|
+
* Deprecated returning `nil` from `column_for_attribute` when no column
|
640
|
+
exists. It will return a null object in Rails 5.0.
|
641
|
+
([Pull Request](https://github.com/rails/rails/pull/15878))
|
640
642
|
|
641
|
-
*
|
642
|
-
|
643
|
-
|
644
|
-
([
|
643
|
+
* Deprecated using `.joins`, `.preload` and `.eager_load` with associations
|
644
|
+
that depend on the instance state (i.e. those defined with a scope that
|
645
|
+
takes an argument) without replacement.
|
646
|
+
([Commit](https://github.com/rails/rails/commit/ed56e596a0467390011bc9d56d462539776adac1))
|
645
647
|
|
646
|
-
|
647
|
-
|
648
|
-
|
648
|
+
### Notable changes
|
649
|
+
|
650
|
+
* Added a `:required` option to singular associations, which defines a
|
651
|
+
presence validation on the association.
|
652
|
+
([Pull Request](https://github.com/rails/rails/pull/16056))
|
649
653
|
|
650
654
|
* `ActiveRecord::Dirty` now detects in-place changes to mutable values.
|
651
|
-
Serialized attributes on
|
655
|
+
Serialized attributes on Active Record models are no longer saved when
|
652
656
|
unchanged. This also works with other types such as string columns and json
|
653
657
|
columns on PostgreSQL.
|
654
658
|
(Pull Requests [1](https://github.com/rails/rails/pull/15674),
|
655
659
|
[2](https://github.com/rails/rails/pull/15786),
|
656
660
|
[3](https://github.com/rails/rails/pull/15788))
|
657
661
|
|
658
|
-
*
|
659
|
-
|
662
|
+
* Introduced the `db:purge` Rake task to empty the database for the
|
663
|
+
current environment.
|
664
|
+
([Commit](https://github.com/rails/rails/commit/e2f232aba15937a4b9d14bd91e0392c6d55be58d))
|
665
|
+
|
666
|
+
* Introduced `ActiveRecord::Base#validate!` that raises
|
667
|
+
`ActiveRecord::RecordInvalid` if the record is invalid.
|
668
|
+
([Pull Request](https://github.com/rails/rails/pull/8639))
|
669
|
+
|
670
|
+
* Introduced `validate` as an alias for `valid?`.
|
671
|
+
([Pull Request](https://github.com/rails/rails/pull/14456))
|
672
|
+
|
673
|
+
* `touch` now accepts multiple attributes to be touched at once.
|
674
|
+
([Pull Request](https://github.com/rails/rails/pull/14423))
|
660
675
|
|
661
|
-
* PostgreSQL
|
676
|
+
* The PostgreSQL adapter now supports the `jsonb` datatype in PostgreSQL 9.4+.
|
677
|
+
([Pull Request](https://github.com/rails/rails/pull/16220))
|
678
|
+
|
679
|
+
* The PostgreSQL and SQLite adapters no longer add a default limit of 255
|
662
680
|
characters on string columns.
|
663
681
|
([Pull Request](https://github.com/rails/rails/pull/14579))
|
664
682
|
|
683
|
+
* Added support for the `citext` column type in the PostgreSQL adapter.
|
684
|
+
([Pull Request](https://github.com/rails/rails/pull/12523))
|
685
|
+
|
686
|
+
* Added support for user-created range types in the PostgreSQL adapter.
|
687
|
+
([Commit](https://github.com/rails/rails/commit/4cb47167e747e8f9dc12b0ddaf82bdb68c03e032))
|
688
|
+
|
665
689
|
* `sqlite3:///some/path` now resolves to the absolute system path
|
666
690
|
`/some/path`. For relative paths, use `sqlite3:some/path` instead.
|
667
691
|
(Previously, `sqlite3:///some/path` resolved to the relative path
|
668
|
-
`some/path`. This
|
692
|
+
`some/path`. This behavior was deprecated on Rails 4.1).
|
669
693
|
([Pull Request](https://github.com/rails/rails/pull/14569))
|
670
694
|
|
671
|
-
* Introduced `#validate` as an alias for `#valid?`.
|
672
|
-
([Pull Request](https://github.com/rails/rails/pull/14456))
|
673
|
-
|
674
|
-
* `#touch` now accepts multiple attributes to be touched at once.
|
675
|
-
([Pull Request](https://github.com/rails/rails/pull/14423))
|
676
|
-
|
677
695
|
* Added support for fractional seconds for MySQL 5.6 and above.
|
678
696
|
(Pull Request [1](https://github.com/rails/rails/pull/8240),
|
679
697
|
[2](https://github.com/rails/rails/pull/14359))
|
680
698
|
|
681
|
-
* Added
|
682
|
-
([Pull Request](https://github.com/rails/rails/pull/
|
699
|
+
* Added `ActiveRecord::Base#pretty_print` to pretty print models.
|
700
|
+
([Pull Request](https://github.com/rails/rails/pull/15172))
|
683
701
|
|
684
|
-
*
|
685
|
-
|
702
|
+
* `ActiveRecord::Base#reload` now behaves the same as `m = Model.find(m.id)`,
|
703
|
+
meaning that it no longer retains the extra attributes from custom
|
704
|
+
`SELECT`s.
|
705
|
+
([Pull Request](https://github.com/rails/rails/pull/15866))
|
686
706
|
|
707
|
+
* `ActiveRecord::Base#reflections` now returns a hash with string keys instead
|
708
|
+
of symbol keys. ([Pull Request](https://github.com/rails/rails/pull/17718))
|
709
|
+
|
710
|
+
* The `references` method in migrations now supports a `type` option for
|
711
|
+
specifying the type of the foreign key (e.g. `:uuid`).
|
712
|
+
([Pull Request](https://github.com/rails/rails/pull/16231))
|
687
713
|
|
688
714
|
Active Model
|
689
715
|
------------
|
@@ -701,11 +727,14 @@ Please refer to the [Changelog][active-model] for detailed changes.
|
|
701
727
|
([Pull Request](https://github.com/rails/rails/pull/16180))
|
702
728
|
|
703
729
|
* Deprecated `ActiveModel::Dirty#reset_changes` in favor of
|
704
|
-
|
730
|
+
`clear_changes_information`.
|
705
731
|
([Pull Request](https://github.com/rails/rails/pull/16180))
|
706
732
|
|
707
733
|
### Notable changes
|
708
734
|
|
735
|
+
* Introduced `validate` as an alias for `valid?`.
|
736
|
+
([Pull Request](https://github.com/rails/rails/pull/14456))
|
737
|
+
|
709
738
|
* Introduced the `restore_attributes` method in `ActiveModel::Dirty` to restore
|
710
739
|
the changed (dirty) attributes to their previous values.
|
711
740
|
(Pull Request [1](https://github.com/rails/rails/pull/14861),
|
@@ -719,10 +748,6 @@ Please refer to the [Changelog][active-model] for detailed changes.
|
|
719
748
|
characters if validations are enabled.
|
720
749
|
([Pull Request](https://github.com/rails/rails/pull/15708))
|
721
750
|
|
722
|
-
* Introduced `#validate` as an alias for `#valid?`.
|
723
|
-
([Pull Request](https://github.com/rails/rails/pull/14456))
|
724
|
-
|
725
|
-
|
726
751
|
Active Support
|
727
752
|
--------------
|
728
753
|
|
@@ -753,15 +778,15 @@ Please refer to the [Changelog][active-support] for detailed changes.
|
|
753
778
|
|
754
779
|
### Notable changes
|
755
780
|
|
756
|
-
*
|
757
|
-
([Commit](https://github.com/rails/rails/commit/5e51bdda59c9ba8e5faf86294e3e431bd45f1830),
|
758
|
-
[Pull Request](https://github.com/rails/rails/pull/17361))
|
759
|
-
|
760
|
-
* Introduced new configuration option `active_support.test_order` for
|
781
|
+
* Introduced a new configuration option `active_support.test_order` for
|
761
782
|
specifying the order test cases are executed. This option currently defaults
|
762
783
|
to `:sorted` but will be changed to `:random` in Rails 5.0.
|
763
784
|
([Commit](https://github.com/rails/rails/commit/53e877f7d9291b2bf0b8c425f9e32ef35829f35b))
|
764
785
|
|
786
|
+
* `Object#try` and `Object#try!` can now be used without an explicit receiver in the block.
|
787
|
+
([Commit](https://github.com/rails/rails/commit/5e51bdda59c9ba8e5faf86294e3e431bd45f1830),
|
788
|
+
[Pull Request](https://github.com/rails/rails/pull/17361))
|
789
|
+
|
765
790
|
* The `travel_to` test helper now truncates the `usec` component to 0.
|
766
791
|
([Commit](https://github.com/rails/rails/commit/9f6e82ee4783e491c20f5244a613fdeb4024beb5))
|
767
792
|
|
@@ -769,7 +794,7 @@ Please refer to the [Changelog][active-support] for detailed changes.
|
|
769
794
|
(Commit [1](https://github.com/rails/rails/commit/702ad710b57bef45b081ebf42e6fa70820fdd810),
|
770
795
|
[2](https://github.com/rails/rails/commit/64d91122222c11ad3918cc8e2e3ebc4b0a03448a))
|
771
796
|
|
772
|
-
* `Object#with_options` can now be used without an explicit receiver.
|
797
|
+
* `Object#with_options` can now be used without an explicit receiver in the block.
|
773
798
|
([Pull Request](https://github.com/rails/rails/pull/16339))
|
774
799
|
|
775
800
|
* Introduced `String#truncate_words` to truncate a string by a number of words.
|