Read more

Associations named using a string cannot be included in a scope

Deleted user #6
January 27, 2012Software engineer

If you defined your association via

class Article
  belongs_to "category"
end
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

and you try

Article.scoped(:include => :category)

you will get an error message

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

Solution

Always define your assocations via symbol

class Article
  belongs_to :category
end  
Posted to makandra dev (2012-01-27 17:10)