Using :group, :having, :select etc with eager loading throug

I’m sure I’ve seen this on the list before, but I can’t find anything in
the
search.

The problem is that using :include in an ActiveRecord::Base#find aliases
all
the columns, making it impossible to use some of the other find
parameters

What’s the usual solution to this?

Gareth

Gareth A. wrote:

I’m sure I’ve seen this on the list before, but I can’t find anything in the
search.

The problem is that using :include in an ActiveRecord::Base#find aliases all
the columns, making it impossible to use some of the other find parameters

What’s the usual solution to this?

You will have to forgo eager loading and either load the records of the
other models in separate queries, or use the :joins and :select options
to
pull fields of interest in the other models into the base model.


We develop, watch us RoR, in numbers too big to ignore.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs