jbox-web / ajax-datatables-rails

A wrapper around DataTable's ajax methods that allow synchronization with server-side pagination in a Rails app
MIT License
590 stars 227 forks source link

Father list loading all child items #257

Closed llermaly closed 7 years ago

llermaly commented 7 years ago

Hello, I'm using this gem for my project but when I list "father" relation elements, all childs are loading unnecessary and this makes my system very slow (2k records) .

Models:

instrument belongs_to evaluation evaluation has_many questions

Problem is I'm listing instruments and all questions inside evaluations are being loaded too (+40 per record)

This is the query that gets the records :

 def get_raw_records
    Instrument.includes(
      :evaluation => [:assignature,:level, :evaluation_type])
    .references(
      :evaluation => [:assignature,:level,:evaluation_type]
      ).distinct
  end

Some simpler queries like Instrument.joins(:evaluation) have problems on sorting/ordering.

I hope you guys can help me.

Thanks

llermaly commented 7 years ago

Forget it, an action button was doing it.

thanks for this nice plugin!!