Fix typo in set_callback docs. [ci skip]
Merge pull request #12148 from gzohari/callback-typo

Fix typo in set_callback docs. [ci skip]
Do not use instance variables if they are not reused elsewhere
Fix failure with minitest 5.0.7

Require minitest/mock in test where stub method is needed.

Apparently this was being "imported" by minitest pride plugin, which
previously required "minitest/autorun", that required "minitest/mock",
making the method available by chance.

It has been changed in minitest:
https://github.com/seattlerb/minitest/commit/595ce955c0d89575726d10fc18d2afd8f334bcbe

So we need to make sure we require what we really need where necessary.
ensure @model_class is initialized
don't depend on object state when reading fixture files
auto link hm:t fixture join tables like habtm
make the duplicate code more similar
reduce duplication somewhat
Use Ruby on Rails Coding Conventions for code examples in the guides

* Indent after private/protected
* Ruby >= 1.9 syntax for hashes
* Prefer method { do_stuff } instead of method{do_stuff} for single-line blocks.

[ci skip]
use polymorphic proxies to remove duplicate code
hm:t join tables may not have a primary key
Merge pull request #12155 from jetthoughts/reformat_guides_code_examples

Use Ruby on Rails Coding Conventions for code examples in the guides
Respond to PUT/PATCH API request with :ok

This commits changes the behavior of `respond_to` for successful PUT/PATCH
requests on format associated with APIs, such as :xml and :json.

Previously, `respond_to` would just return :no_content (204) and no body.
After this commit, it returns :ok (200) and the entire updated object as
the response body.

The rationale behind this commit is that a PUT, POST or PATCH call may make
modifications to fields of the underlying resource that weren't part of the
provided parameters (for example: created_at or updated_at timestamps).

This commit prevents an API consumer from having to hit the API again for an
updated representation. Rails already provides the created representation after
a POST, so it is coherent to have the same behavior on PUT and PATCH.