-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 5.1.4
-
Component/s: None
-
None
recently in Mongoid gem there have been added possibility to include nested models: User.includes(:address, friends: [:address, :followers]) (https://jira.mongodb.org/browse/MONGOID-4173)
Lets say I have following models:
class Pages::Continent
has_many :contries, class_name: "Pages::Country"
end
class Pages::Country
belongs_to :continent, class_name: "Pages::Continent"
has_many :contries, class_name: "Pages::Cities"
end
class Pages::City
belongs_to :continent, class_name: "Pages::Country"
end
While trying to select continents including countries and cities:
@continents = Pages::Continent.includes(countries: [:cities])
I receive the error: NameError (uninitialized constant Country) which probably means that it does not look for Pages::Country but just for Country model (however as you can see class_name attributes are specified for each model)