rails/rails — pull request #9522 by wangjohn (2013-03-02 22:01:44+00:00)
Title: Finding inverse associations automatically

If you don't define ``inverse_of'' in an association, then you don't get the performance benefits of the inverse associations. However, these inverses can often times be guessed automatically. I'm adding functionality that will do some simple guesses if the ``inverse_of'' has not been set in an association.

For example, let's say we have two models Post and Comment:
```ruby
class Post < ActiveRecord::Base
has_one :comment
end

class Comment < ActiveRecord::Base
belongs_to :post
end
```

The code I'm adding will automatically find that the post and comments are inverses of each other, so that the result is that the above code is equivalent to this:
```ruby
class Post < ActiveRecord::Base
has_one :comment, :inverse_of => :post
end

class Comment < ActiveRecord::Base
belongs_to :post, :inverse_of => :comment
end
```

Note that I've removed some tests which no longer make any sense (they were asserting that inverses were nil, but the new functionality means that they actually do find an inverse automatically).