In this tutorial we walk through how to create and use a counter cache in a Ruby on Rails 6 application. In a previous tutorial we added a has many through relationship between videos and categories. This week we add a counter cache column to our database on the join relationship. Don't worry I walk through the entire process from creating database migrations, populating our legacy data, updating our relationship and views, and finally deploying to production.
⏰ Timestamps
0:00 Introduction
1:44 Previous setup
2;41 Create Git branch
2:53 problem demonstration
4:49 What is a counter cache
5:41 Database migration
631 Update relationship
8:12 Create a Service
10:45 Another database migration
13:04 Verify increment
13:37 Verify decrement
14:36 Use counter cache
16:20 Create a task
17:50 Push to GitHub
18:58 Deploy
19:28 Verify Production
20:49 Closing notes
Videos Referenced
How to Add Categories and Filtering (Has Many Through Relationships)
• How to Add Categories and Filtering (Has M...
How to use Git and GitHub for your Rails Application
• How to use Git and GitHub for your Rails A...
How to Create and Use an SSH Config File Tutorial in Less Than 3 Minutes
• How to Create and Use an SSH Config File T...
AWS + Rails Series Playlist
• AWS + Rails
My Gear List
http://brain-trust.io/my-gear
My YouTube SEO Software
https://www.tubebuddy.com/braintrust
My Accounting Software
https://shareasale.com/r.cfm?b=960179...
Try Audible and Get Two Free Audiobooks
https://amzn.to/36dXe3V
Make sure you subscribe to my channel to keep up to date with new content!
DISCLAIMER: Links in this description include affiliate links. If you purchase a product or service with the links that I provide I may receive a small commission. There is no additional charge to you! Thank you for supporting BrainTrust Digital so I can continue to provide you with free content each week!