Posted about 7 years ago. Visible to the public.

Associations named using a string cannot be included in a scope

If you defined your association via

Copy
class Article belongs_to "category" end

and you try

Copy
Article.scoped(:include => :category)

you will get an error message

Copy
in `preload_one_association': Association named 'category' was not found; perhaps you misspelled it? (ActiveRecord::ConfigurationError)

Solution

Always define your assocations via symbol

Copy
class Article belongs_to :category end

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Martin Straub
Last edit:
almost 7 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Martin Straub to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more