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

18.55 Muhamad Akbar Bin Widayat 0 Comments

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. :)

0 komentar:

terimakasih komentarnya