This project is archived and is in readonly mode.
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
-
Adam December 31st, 2008 @ 08:20 PM
I just came across a similar issue [#1129] that was fixed and this ticket just fixes up the reassign case that was missed as the column name was set in two different places. This patch also moves it to one method.
-
Repository March 6th, 2009 @ 10:09 PM
- State changed from new to resolved
(from [3ca5a0f9fd7b7921bca970859da8637011b22dd1]) Ensure belongs_to association with a counter cache in name spaced model works [#1678 state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...
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
- 1678 Namespaced models in belongs to with counter cache set (from [3ca5a0f9fd7b7921bca970859da8637011b22dd1]) Ensure ...