Code Explainers
Code explainers tagged #counter-cache
ruby
class Comment < ApplicationRecord belongs_to :commentable, polymorphic: true, counter_cache: true belongs_to :author, class_name: "User"
How polymorphic comments work in Rails
polymorphic-association
concerns
counter-cache
Intermediate
8 steps
ruby
class CreateCommentsWithCounterCache < ActiveRecord::Migration[7.1] def change create_table :posts do |t| t.string :title, null: false
How counter caches work in Rails
counter-cache
migrations
associations
Intermediate
6 steps