Possible bug with has_many and Array#empty?

I've pasted the code where I have a problem here:
http://progress-vs-perfection.blogspot.com/2007/11/issue-with-arrayempty.html

The bottom line is this: I have an object called document_group that
has many document_templates. In my controller, I create class
variable like so:

   @document_group_templates = @document_group.document_templates

Then, in my view I have to decide to do some rendering, so I do this:

  if !@document_group_templates.empty?
     ...do stuff
  end

The issue is that .empty? always evaluates to true. For whatever
reason, the collection of document_templates on the document_group
does not get initialized.

I can look in my log file and see that the SQL to populate the array
is not triggered. That said,

a) if I do something such as @document_group_templates.inspect that
triggers the SQL to run that populates the array

b) if I do

  if @document_group_templates.count > 0
    ...do stuff
  end

the #count method also triggers the SQL to run.

All that said, shouldn't this statement:

   @document_group_templates = @document_group.document_templates

have triggered the SQL to load the array in the first place? Is that
a bug of some sort?

Josh--

I didn't file a ticket. What is the ticket you are referring to?

Scott

I'm not sure, but I don't think that is the same issue.

Ticket 10115 and 8049 address cases where:
  -- an object is being created using #new,
  -- another object is being appended to an array of which the new
object has many.
  -- #empty? is being evaluated before the object has been saved to
the DB

In my case, the code is:
  -- creating an object A using #find,
  -- the object B in the array on object A already existed as data in
the database
  -- then I'm evaluating #empty?

In my case, the code is:
-- creating an object A using #find,
-- the object B in the array on object A already existed as data in
the database
-- then I'm evaluating #empty?

Stab in the dark: if you remove your use of counter cache, does the
problem go away?

Fred