is_taggable icon indicating copy to clipboard operation
is_taggable copied to clipboard

Eager loading?

Open barmstrong opened this issue 16 years ago • 1 comments

Has anyone got eager loading working with this?

I'm trying a line like this: :include => {:taggings => :tags}

but it doesn't seem to be working. Thanks for the great plugin!

barmstrong avatar Dec 16 '09 21:12 barmstrong

WOW finally got this figured out.

Actually the eager loading was working correctly and can even be done simpler, like this: :include => :tags

The reason I thought it wasn't working was I was seeing database calls to load tags for each object. It turned out using 'tag_list' was making another database call even though the objects were in memory.

In my form to edit an object (lots of them on one page) I had a line like this: <%= f.text_field :tag_list %>

This is what was making another database call. I was able to hard code in the value like this, to prevent it from making another call:

<%= f.text_field :tag_list, :value => my_object.tags.collect{|t|t.name}.join(', ') %>

Anyway, awesome plugin! Hope this helps someone else.

barmstrong avatar Dec 16 '09 22:12 barmstrong