SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: shovell
-
Sep 24, 2008, 06:29 #1
- Join Date
- Sep 2008
- Posts
- 2
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
shovell
Hi,
just finished Simply Rails 2, and can't get the counter_cache to work.
Searched the forum but could not find anything.
any newly created story is supposed to have :votes_count = 1 but i keep getting nil when i check in console and story doesn't come up on "Upcoming stories page". the code is identical with the book (or code archive)
Any suggestions and help would be much appreciated.
Thanks.
-
Sep 24, 2008, 09:48 #2
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
Hi vvan, welcome to the forums.
Chapter 9 has quite a bit to it. For example, the Vote model is changed to
Code Ruby:class Vote < ActiveRecord::Base belongs_to :user belongs_to :story, :counter_cache => true end
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
Sep 24, 2008, 15:17 #3
- Join Date
- Sep 2008
- Posts
- 2
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
Thanks for the reply but the problem was in the migration file to add the counter cache.
There is a screencast at railscast for this, episode 23, it requires another line of code Story.reset_column_information just before Story.findall).each block.
This fixed it all.
Thanks again.
Bookmarks