Counter Culture

Episode #435 by Teacher's Avatar David Kimura

Summary

The provided ActiveRecord counter caching mechanism provides some great basic functionality, but quickly becomes insufficient if you need more complex totaling or summing of records. In this episode, we'll look at implementing the counter_culture gem to gain extra functionality.
rails model 14:02

Chapters

  • Introduction (0:00)
  • Adding the gem (1:37)
  • Generating models (1:50)
  • Setting up associations (2:25)
  • Adding counter_culture to models (2:39)
  • Testing the counts (4:47)
  • Viewing the results (6:02)
  • Seeding with many records (7:56)
  • Regenerating the counts (8:34)
  • Creating models for many to many (9:37)
  • Adding counter_culture to models (10:49)
  • Testing the counts (11:41)
  • Viewing the results (12:40)
  • Final Thoughts (13:12)
Student & Teacher
$ 9 /mo

Valid School Email Required

Same Access as Pro

Subscribe Now
Pro Monthly
$ 19 /mo

Access to Pro Episodes

Invite to Slack Channel

Priority Suggestions

Ad Free

Subscribe Now
Pro Annual
$ 190 /yr

Access to Pro Episodes

Invite to Slack Channel

Priority Suggestions

Ad Free

Subscribe Now
Teams
$ 57 /mo

3 Users Minimum

$19.00 / user / month

Same Access as Pro

Subscribe to Teams