Remove j alias for ERB::Util.json_escape
Fix GH #4259. We must remove table_name_prefix and table_name_suffix, when we execute schema dumper.
Fix eagerly loading associations without primary keys
Unset association when existing record is destroyed.

To avoid foreign key errors (and invalid data) in the database, when a belongs_to association is destroyed, it should also be nil'd out on the parent object.
Prevent concurrent compilation of templates - closes #6400

This addresses an issue where in multi-threaded environments
multiple threads can attempt to compile a template at the same time,
which occasionally causes particular templates to end up in a bad
state.

So, add synchronization such that only a single thread can attempt to
compile a template at one time.
Make the Resolver template cache threadsafe  - closes #6404

The Template cache in the Resolver can be accessed by multiple threads
similtaneously in multi-threaded environments. The cache is implemented
using a Hash, which isn't threadsafe in all VMs (notably JRuby).

This commit extracts the cache to a new Cache class and adds mutexes to
prevent concurrent access.
More granular locking of the Resolver template cache

In order to avoid holding a global lock when doing template
resolution, instead add individual locks on a per cache entry
basis. The global lock is now only used for manipulation of the main
cache data structure.
Improve the readability of the Resolver change detection code
Cache metadata in advance to avoid extra sql statements while testing.

Reason: If metadata is not cached extra sql statements
will be executed, which causes failures tests with assert_queries().
Make connection pool fair with respect to waiting threads.

The core of this fix is a threadsafe, fair Queue class.  It is
very similar to Queue in stdlib except that it supports waiting
with a timeout.

The issue this solves is that if several threads are contending for
database connections, an unfair queue makes is possible that a thread
will timeout even while other threads successfully acquire and release
connections.  A fair queue means the thread that has been waiting the
longest will get the next available connection.

This includes a few test fixes to avoid test ordering issues that
cropped up during development of this patch.
Fix typo [ci skip]
update ActiveModel::Dirty documentation
routes are viewable in browser (update guides)

From the Pull Request #6461
Update guides/code/getting_started/config/routes.rb
Update guides/code/getting_started/app/controllers/home_controller.rb
the file name should be changed to home_helper.rb
Update guides/code/getting_started/test/functional/home_controller_test.rb
change welcome_helper.rb to home_helper.rb
Revert some ActiveSupport::Callbacks changes.

This reverts commits 911a0859ac065aa8e8834ac985353d659c7c7b65 and
30b31f51af6f7094c4a27b086755fc66c368d6fa.

Reason: these changes make the Active Model tests fail randomly.

Some examples:
http://travis-ci.org/#!/rails/rails/jobs/1498992
http://travis-ci.org/#!/rails/rails/jobs/1496948
http://travis-ci.org/#!/rails/rails/jobs/1489985

This script was used to reproduce these breaks:
https://gist.github.com/f6828a03ee4d40bffbc3

200 times, 0 failures
better explanations for acts_like?, try and deep_dup