Closed jbwl closed 8 years ago
Can you try smth like
@tasks_grid = initialize_grid(Task,
include: :project,
conditions: {archived: false, project: {active: true}}
)
Thank you for the reply. Your code results in 2 queries (one for Thing, and one for all the Stuff objects with a "IN (A,B,C)" condition. Much better.
Just out of interest, is there a possibility to use a relation in Wice Grid and have a true "Eager Load" of related objects through a "LEFT OUTER JOIN" query? This is the default for an AR .eager_load(:stuff) call, but if I use this, I don't know how to reference stuff columns in the view without Wice Grid producing N+1 queries.
Thanks again.
Your code results in 2 queries
No, this is what ActiveRecord does with a corresponding AR call. The plugin does not use AR .eager_load
internally
Thanks. I would like to request the possibility to make Wice Grid use .eager_load internally then.
This plugin is looking for maintainers. I am not adding anything to it.
On Wice Grid 3.5.0 with Rails 3, I am using the following ActiveRecord finder:
to initialize the grid.
In the view, I am referencing the stuff columns like this:
This results in the stuff attribute pulled from the database for each row (N+1) - even though it has already been loaded in the AR call, and the performance is accordingly bad.
Am I referencing the stuff column in the wrong way? I have found no solution in the manual.