remove variable and fix warning
Merge pull request #10536 from vipulnsward/fix_exp_warning

remove variable and fix warning
Merge pull request #10535 from vipulnsward/remove_var

remove redundant var
changed rails -> Rails at two places
Added documentation for ActiveRecord::Base#next_migration_number
Added documentation for ActiveRecord::Generators::MigrationGenerator.next_migration_number
Document ActionMailer::Base::default, ::mailer_name, and #mailer_name
RDoc style for ActionMailer::Base#mail
Remove unnecessary require from active_support/inflector/methods.rb

`active_support/inflections` already requires
`active_support/inflector/inflections`. There's no need to require it in
`active_support/inflector/methods`.
sort => sort! on new array
[ci skip] document protect_against_forgery? method
Merge pull request #10510 from think602/master

[ci skip] document protect_against_forgery? method
Set the inverse when association queries are refined

Suppose Man has_many interests, and inverse_of is used.

Man.first.interests.first.man will correctly execute two queries,
avoiding the need for a third query when Interest#man is called. This is
because CollectionAssociation#first calls set_inverse_instance.

However Man.first.interests.where("1=1").first.man will execute three
queries, even though this is obviously a subset of the records in the
association.

This is because calling where("1=1") spawns a new Relation object from
the CollectionProxy object, and the Relation has no knowledge of the
association, so it cannot set the inverse instance.

This commit solves the problem by making relations spawned from
CollectionProxies return a new Relation subclass called
AssociationRelation, which does know about associations. Records loaded
from this class will get the inverse instance set properly.

Fixes #5717.

Live commit from La Conf! :sparkles:
Merge pull request #10543 from vipulnsward/to_sort

Can you improve the commit message a little bit? It's good to describe why the change is happening.
Fix that #exists? can produce invalid SQL: "SELECT DISTINCT DISTINCT"

The combination of a :uniq => true association and the #distinct call
in #construct_limited_ids_condition combine to create invalid SQL, because
we're explicitly selecting DISTINCT, and also sending #distinct on to AREL,
via the relation#distinct_value.

Rather than build a select distinct clause in #construct_limited_ids_condition,
I set #distinct! and pass just the columns into the select statement.
This requires introducing a #columns_for_distinct method to return the
select columns but not the statement itself.
Don't try to EXPLAIN select_db calls
Merge pull request #10553 from dasch/dasch/dont-try-to-explain-select_db

Don't try to EXPLAIN select_db calls
Merge pull request #6792 from Empact/postgres-distinct

Fix that #exists? can produce invalid SQL: "SELECT DISTINCT DISTINCT"
Move #proxy_association method to AssociationRelation
Reject blank order_values within #columns_for_distinct, as the orders aren't used at all on non-postgres adapters.