rails/rails — pull request #7418 by oruen (2012-08-22 09:04:23+00:00)
Title: Using strings in association definition methods breaks eager loading

ActiveRecord::Associations::Preloader#records_by_reflection uses symbolized association name to find a reflection. If association was defined using string as it's name, model reflections hash would contain that string as a key — so Preloader fails to find that reflection. I think storing symbolized association names in reflections hash is a good solution.

Failing example:
```ruby
class Post < ActiveRecord::Base
belongs_to "author"
end

class Author < ActiveRecord::Base
has_many :posts
end
```
rails> Post.includes(:author).where(:id => 1)
ActiveRecord::ConfigurationError: Association named 'author' was not found; perhaps you misspelled it?