ruby - Rails - Nested includes on Active Records? -



ruby - Rails - Nested includes on Active Records? -

i have list of events fetch. i'm trying include every user associated event , every profile associated each user. users included not profiles.

how this

event.includes(:users [{profile:}])

the docs don't seem clear: http://guides.rubyonrails.org/active_record_querying.html

i believe next should work you.

event.includes(users: :profile)

if want include association (we'll phone call c) of included association (we'll phone call b), you'd utilize syntax above. however, if you'd include d well, association of b, that's when you'd utilize array given in illustration in rails guide.

a.includes(bees: [:cees, :dees])

you go on nest includes (if need to). associated z, , c associated e , f.

a.includes( { bees: [ { cees: [:ees, :effs] }, :dees] }, :zees)

and fun, we'll e associated j , x, , d associated y.

a.includes( { bees: [ { cees: [ { ees: [:jays, :exes] }, :effs] }, { dees: :wise } ] }, :zees)

ruby-on-rails ruby rails-activerecord nested-includes

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -