Forum: Ruby on Rails acts_as_tree counter_cache behavior is different than API do

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D. Taylor S. (Guest)
on 2006-02-03 20:34
(Received via mailing list)
Before I file a ticket, I'll query ya'll about this:

The API docs for acts_as_tree's counter_cache is to create a database
called "children_count" to hold the counter_cache. I have enabled this
option in my model. While writing tests I wrote a test for creating
from the a parent:
    message = @forum_message["parent"].find
    child = message.children.create( "member_id" => 1, "forum_id" => 1,
"subject" => 'another subject', "body" => "good grief.")

This follows the the API docs pretty closely at

However, the test fails for this reason:

  4) Error:
ActiveRecord::StatementInvalid: PGError: ERROR:  column
"forum_messages_count" does not exist
: UPDATE forum_message SET forum_messages_count = forum_messages_count +
WHERE (id = 1)

The docs do not mention creating a table column based on the model name.
this the now intended behavior?

Where is it documented and can the name of the column be overridden?

Thank you for any help.

D. Taylor S.
Ezra Z. (Guest)
on 2006-02-04 00:21
(Received via mailing list)
On Feb 3, 2006, at 10:33 AM, D. Taylor S. wrote:

> This follows the the API docs pretty closely at http://
> Rails mailing list
> removed_email_address@domain.invalid


	I ran into the same problem using acts_as_tree to make a small forum
I wrote. You do have to name the *_count column after the tablename
you use it in for things to work correctly. Not sure if the docs are
just wrong or what.

-Ezra Z.
Yakima Herald-Republic
D. Taylor S. (Guest)
on 2006-02-04 00:49
(Received via mailing list)
Thanks for the response. I'll go ahead and file a ticket to fix the
documentation then.

D. Taylor S.
This topic is locked and can not be replied to.