json - Rails include through Jbuilder partial -


i have jbuilder show renders partial:

json.contents @item_trackers, partial: 'item_trackers/item_tracker', as: :it

in partial access pages_trackers association through it variable:

json.pages it.pages_trackers.order("created_at asc")

the problem when request fired, loads every page_tracker belongs item_tracker (one request each).

i've tried include pages_trackers model in controller: item_trackers.includes([:pages_trackers])

but still loads every page_tracker , have "unused eager loading" message:

unused eager loading detected itemtracker => [:pages_trackers] remove finder: :includes => [:pages_trackers]

can me this?

i found out problem was: when calling order method in partial, forced requests fired again. changed sql method order ruby counterpart: sort_by(&:created_at)


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -