aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorJoel Hawksley <joelhawksley@github.com>2019-06-03 08:27:09 -0600
committerGitHub <noreply@github.com>2019-06-03 08:27:09 -0600
commit60af9db3745f994e8a4bd7afe9dfa6ea8be7bb7c (patch)
tree99c9199bf71835f18e2c746b04abe70569e5baed /guides/source
parenta85c372798723b900762c27e62c35689905327aa (diff)
parentc926ca46280aee795b98206dd0707a96b9423cc5 (diff)
downloadrails-60af9db3745f994e8a4bd7afe9dfa6ea8be7bb7c.tar.gz
rails-60af9db3745f994e8a4bd7afe9dfa6ea8be7bb7c.tar.bz2
rails-60af9db3745f994e8a4bd7afe9dfa6ea8be7bb7c.zip
Merge pull request #2 from rails/master
merge master
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/6_0_release_notes.md4
-rw-r--r--guides/source/active_record_querying.md15
-rw-r--r--guides/source/active_support_core_extensions.md12
-rw-r--r--guides/source/configuring.md2
-rw-r--r--guides/source/testing.md2
-rw-r--r--guides/source/upgrading_ruby_on_rails.md22
6 files changed, 47 insertions, 10 deletions
diff --git a/guides/source/6_0_release_notes.md b/guides/source/6_0_release_notes.md
index fa45e7240d..e421ae1ac7 100644
--- a/guides/source/6_0_release_notes.md
+++ b/guides/source/6_0_release_notes.md
@@ -215,6 +215,10 @@ Please refer to the [Changelog][action-pack] for detailed changes.
### Notable changes
+* Change `ActionDispatch::Response#content_type` returning Content-Type
+ header as it is.
+ ([Pull Request](https://github.com/rails/rails/pull/36034))
+
* Raise an `ArgumentError` if a resource param contains a colon.
([Pull Request](https://github.com/rails/rails/pull/35236))
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index e40f16e62d..5fb030fad4 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -1821,6 +1821,21 @@ Client.limit(1).pluck(:name)
# => ["David"]
```
+NOTE: You should also know that using `pluck` will trigger eager loading if the relation object contains include values, even if the eager loading is not necessary for the query. For example:
+
+```ruby
+# store association for reusing it
+assoc = Company.includes(:account)
+assoc.pluck(:id)
+# SELECT "companies"."id" FROM "companies" LEFT OUTER JOIN "accounts" ON "accounts"."id" = "companies"."account_id"
+```
+
+One way to avoid this is to `unscope` the includes:
+
+```ruby
+assoc.unscope(:includes).pluck(:id)
+```
+
### `ids`
`ids` can be used to pluck all the IDs for the relation using the table's primary key.
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 1a057832d4..21901a7158 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -2633,14 +2633,12 @@ The method `stringify_keys` returns a hash that has a stringified version of the
# => {"" => nil, "1" => 1, "a" => :a}
```
-In case of key collision, one of the values will be chosen. The chosen value may not always be the same given the same hash:
+In case of key collision, the value will be the one most recently inserted into the hash:
```ruby
{"a" => 1, a: 2}.stringify_keys
-# The result could either be
+# The result will be
# => {"a"=>2}
-# or
-# => {"a"=>1}
```
This method may be useful for example to easily accept both symbols and strings as options. For instance `ActionView::Helpers::FormHelper` defines:
@@ -2677,14 +2675,12 @@ The method `symbolize_keys` returns a hash that has a symbolized version of the
WARNING. Note in the previous example only one key was symbolized.
-In case of key collision, one of the values will be chosen. The chosen value may not always be the same given the same hash:
+In case of key collision, the value will be the one most recently inserted into the hash:
```ruby
{"a" => 1, a: 2}.symbolize_keys
-# The result could either be
+# The result will be
# => {:a=>2}
-# or
-# => {:a=>1}
```
This method may be useful for example to easily accept both symbols and strings as options. For instance `ActionController::UrlRewriter` defines
diff --git a/guides/source/configuring.md b/guides/source/configuring.md
index 0b54683b5a..cc64c7eac6 100644
--- a/guides/source/configuring.md
+++ b/guides/source/configuring.md
@@ -69,7 +69,7 @@ These configuration methods are to be called on a `Rails::Railtie` object, such
* `config.cache_classes` controls whether or not application classes and modules should be reloaded on each request. Defaults to `false` in development mode, and `true` in test and production modes.
* `config.beginning_of_week` sets the default beginning of week for the
-application. Accepts a valid week day symbol (e.g. `:monday`).
+application. Accepts a valid day of week as a symbol (e.g. `:monday`).
* `config.cache_store` configures which cache store to use for Rails caching. Options include one of the symbols `:memory_store`, `:file_store`, `:mem_cache_store`, `:null_store`, `:redis_cache_store`, or an object that implements the cache API. Defaults to `:file_store`.
diff --git a/guides/source/testing.md b/guides/source/testing.md
index 9540bb2af5..41bc54b924 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -1144,7 +1144,7 @@ test "ajax request" do
get article_url(article), xhr: true
assert_equal 'hello world', @response.body
- assert_equal "text/javascript", @response.content_type
+ assert_equal "text/javascript", @response.media_type
end
```
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index b8a5c39f39..1110592d5e 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -134,6 +134,28 @@ Action Cable JavaScript API:
+ ActionCable.logger.enabled = false
```
+### `ActionDispatch::Response#content_type` now returned Content-Type header as it is.
+
+Previously, `ActionDispatch::Response#content_type` returned value does NOT contain charset part.
+This behavior changed to returned Content-Type header containing charset part as it is.
+
+If you want just MIME type, please use `ActionDispatch::Response#media_type` instead.
+
+Before:
+
+```ruby
+resp = ActionDispatch::Response.new(200, "Content-Type" => "text/csv; header=present; charset=utf-16")
+resp.content_type #=> "text/csv; header=present"
+```
+
+After:
+
+```ruby
+resp = ActionDispatch::Response.new(200, "Content-Type" => "text/csv; header=present; charset=utf-16")
+resp.content_type #=> "text/csv; header=present; charset=utf-16"
+resp.media_type #=> "text/csv"
+```
+
### Autoloading
The default configuration for Rails 6