rails/rails — pull request #7377 by brainopia (2012-08-17 13:56:57+00:00)
Title: Use inversed parent for first and last child of has_many association

Currently invoking `#first/#last` on not-loaded collection proxy for `has_many` association will not set inversed parent for fetched record. So example from rails guides and docs is actually not correct:

```ruby
c = Customer.first
o = c.orders.first
c.first_name == o.customer.first_name # => true
c.first_name = 'Manny'
c.first_name == o.customer.first_name # => true
```

In reality last line will return false. I've fixed both methods to take `inversed_of` option into account. So now this example will work as intented, I've provided test to illustrate it.