See associations below:
class Continent < ActiveRecord::Base
has_many :countrys
class Country < ActiveRecord::Base
belongs_to :continent
has_many :addresses
class Address < ActiveRecord::Base
belongs_to :person
belongs_to :street
class Person < ActiveRecord::Base
has_many :addresses
How can I start with Person.includes()
and include associations all the way up to the continent when querying the db.
I've been able to include up to the country via .includes(addresses: :country)
, however it seems not to get the last level.
You can add 1 more level of hash:
.includes(addresses: {country: :continent})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With