fix inverse_of when find_or_initialize_by_*

inverse_of relation was not being set when calling find_or_initialize_by_ and the entry was
found on the db.
Merge pull request #12375 from arthurnn/inverse_after_find_or_initialize

Inverse after find or initialize
Move set_inverse_instance to association.build_record

[fixes #10371]
Merge pull request #12413 from arthurnn/inverse_of_on_build

Inverse of on build
make sure both headers are set before checking for ip spoofing

Conflicts:
	actionpack/lib/action_dispatch/middleware/remote_ip.rb