Rails Ancestry Named scope 'to_depth' is only available when depth caching is enabled

Hi Everyone,

I will share to you about my experience when had error "Named scope 'to_depth' is only available when depth caching is enabled". Please try below:

1. Add new migration
    - Migrate: add_column [tables], :ancestry_depth, :integer, :default => 0
    - Build cache: TreeNode.rebuild_depth_cache!
2. Go to model
    -  has_ancestry cache_depth: true

I hope this article can help you. :)

Comments

Popular posts from this blog

Riset Kebutuhan & Jasa Pembuatan Website UMKM (Riset Lapangan Jakarta Barat)

5 Nilai Inti (GCG) Wajib Sebelum Merancang Produk Digital

Kesalahan Pindah Blogspot ke Domain Pribadi Berujung Domain Blogspot Lenyap