rails/rails — pull request #7273 by beerlington (2012-08-06 01:01:39+00:00)
Title: Convert model name to foreign key in queries

This allows you to specify the model in a `belongs_to` relationship instead of the foreign key when querying. It does this by looking up the correct foreign key on the association, and changing the column to use that key when appropriate. It came out of a discussion in issue #1736 that seemed to have some interest.

The following queries are now equivalent:

```ruby
Post.where(:author_id => Author.first)
Post.where(:author => Author.first)
```

I also think it makes it more consistent with `has_many` queries where the relationship and query key are both plural:

```ruby
posts = Post.containing_the_letter_a.limit(5)
Author.where(:posts => posts)
```