Save has_one associations only if record has changes

Prevents save related callbacks such as `after_commit` being
triggered when `has_one` objects are already persisted and have no
changes.
Only use BINARY for mysql case sensitive uniqueness check when column has a case insensitive collation.
Handle missing environment from non empty config

If using a `DATABASE_URL` and a `database.yml`. The connection information in `DATABASE_URL` should be merged into whatever environment we are in. As released in 4.1.0rc1 if someone has a database.yml but is missing a key like production:

```yml
development:
  host: localhost

```

Then the check for blank config will return false so the information from the `DATABASE_URL` will not be used when attempting to connect to the `production` database and the connection will incorrectly fail.

This commit fixes this problem and adds a test for the behavior.

In addition the ability to specify a connection url in a `database.yml` like this:

```
production: postgres://localhost/foo
```

Was introduced in 4.1.0rc1 though should not be used, instead using a url sub key

```
production:
  url: postgres://localhost/foo
```

This url sub key was also introduced in 4.1.0rc1 though the `production: postgres://localhost/foo` was not removed. As a result we should not test this behavior.
typos fixes
Tweak Configuring Guide language

the fact that Rails is multi-thread by default is not very relevant. see https://github.com/rails/rails/pull/13998 [ci skip]
:scissors:

This commit also addresses rails/docrails#169 and rails/rails#14159
Fixed STI classes not defining an attribute method if there is a
conflicting private method defined on its ancestors.

The problem is that `method_defined_within?(name, klass, superklass)`
only works correclty when `klass` and `superklass` are both `Class`es.

If both `klass` and `superklass` are both `Class`es, they share the
same inheritance chain, so if a method is defined on `klass` but not
`superklass`, this method must be introduced at some point between
`klass` and `superklass`.

This does not work when `superklass` is a `Module`. A `Module`'s
inheritance chain contains just itself. So if a method is defined on
`klass` but not on `superklass`, the method could still be defined
somewhere upstream, e.g. in `Object`.

This fix works by avoiding calling `method_defined_within?` with a
module while still fufilling the requirement (checking that the
method is defined withing `superclass` but not is not a generated
attribute method).

4d8ee288 is likely an attempted partial fix for this problem. This
unrolls that fix and properly check the `superclass` as intended.

Fixes #11569.
Simple Sungularize ActionController::UnpermittedParameters error in case when only 1 parameter is unpermitted.
[skip ci] Standardized punctuation.
Merge pull request #14186 from ch33hau/standardized-punctuation

Standardized punctuation.
Merge pull request #14006 from Loremaster/strong_params_improvement

Sungularize ActionController::UnpermittedParameters error in case when only 1 parameter is unpermitted.
`ActionDispatch::Head` was replaced by `Rack::Head`. Closes #14191.

See 449039a86d802871b707dfb51ac1ed96d53526f9 for the original commit.
Add missing parantheses in index_exists?
Point master changelogs to 4-1-stable branch

Remove 4-1 related entries from master [ci skip]
Merge pull request #14193 from ys/patch-1

Add missing parantheses in index_exists?
:scissors: [ci skip]
Optimize getting started guide images, and use png instead of jpg

We noticed the rails gem increased in size between the beta and rc
versions, and the reason is that some guides images were updated but not
properly optimized, and one image changed from png to jpg, way bigger.

Converting the jpg image back to png, and using ImageOptim to optimize
all the images for web view, improves the situation [ci skip].

---

In current master/4-1-stable:

    508K  guides/assets/images/getting_started/

In v4.1.0.beta1:

    268K  guides/assets/images/getting_started/

In 4-0-stable

    328K  guides/assets/images/getting_started/

After the patch:

    260K  guides/assets/images/getting_started/
Skip test_migrate_revert_add_index_with_name if databases
do not allow to create duplicate indexes on the same columns
Merge pull request #14177 from yahonda/skip_tests_if_duplicate_index_not_allowed

Skip test_migrate_revert_add_index_with_name for some databases
Bump version of bcrypt gem