Check if association cached without hitting db?

Is there a way to tell if an association on an object is cached without
hitting the db?

For example, let’s say I have order has_many line_items, is there a way
for me to tell if order.line_items is already populated?

On Oct 20, 12:35 am, Raymond O’Connor <rails-mailing-l…@andreas-
s.net> wrote:

Is there a way to tell if an association on an object is cached without
hitting the db?

For example, let’s say I have order has_many line_items, is there a way
for me to tell if order.line_items is already populated?

I think you can do order.line_items.loaded?

Fred

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