This project is archived and is in readonly mode.

#1678 ✓resolved
Adam

Namespaced models in belongs to with counter cache set

Reported by Adam | December 31st, 2008 @ 08:14 PM | in 2.x

If a namespaced model is referenced in the belongs_to that has a counter_cache => true then the counter cache column name is not properly inferred from the class.

This is an issue during a reassign of the belongs_to association.


>> post = Web::Post.create
=> #<Web::Post id: 1, title: nil, comments_count: nil>
>> post.comments.create
=> #<Web::Comment id: 1, post_id: 1, comment: nil>
>> post.reload
=> #<Web::Post id: 1, title: nil, comments_count: 1>
>> comment = post.comments.first
=> #<Web::Comment id: 1, post_id: 1, comment: nil>
>> comment.post = nil
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: web/comments_count: UPDATE "posts" SET "web/comments_count" = COALESCE("web/comments_count", 0) - 1 WHERE ("id" = 1) 

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages