GithubHelp home page GithubHelp logo

Stack level too deep about cache_digests HOT 2 OPEN

rails avatar rails commented on May 18, 2024
Stack level too deep

from cache_digests.

Comments (2)

mupkoo avatar mupkoo commented on May 18, 2024

I have the same issue, using Rails 4.0.0. When I try to cache a segment with recursion, I get this error:

SystemStackError at /testing-webcast/sections
=============================================

> stack level too deep

activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb, line 23

Here is the code from my app

models/section.rb

class Section < ActiveRecord::Base

    ...

    # Relations
    belongs_to :webcast
    belongs_to :speaker
    belongs_to :parent, class_name: Section
    has_many :children, class_name: Section, foreign_key: :parent_id

    # Scopes
    default_scope -> { order(:position) }
    scope :root, -> { where parent_id: nil }

    ....

end

sections/_webcast.html.erb

<% cache [ 'sections', sections.maximum(:updated_at).to_i ] do %>
    <%= render 'sections/list', sections: sections.root %>
<% end %>

sections/_list.html.erb

<ul>
    <% sections.each do |section| %>
        <li>
            <div class="section webcast animate">
                <h2><%= section.get_title %></h2>
            </div>

            <% if section.children.count > 0 %>
                <%= render 'sections/list', sections: section.children %>
            <% end %>
        </li>
    <% end %>
</ul>

Everything works, if I remove this part.

...
<% if section.children.count > 0 %>
    <%= render 'sections/list', sections: section.children %>
<% end %>
...

Other thing is that, after I remove the part from above, the cache is created.
After this I add the part again to the template, remove the cache manually (delete the files)
and it starts to work.

from cache_digests.

charles avatar charles commented on May 18, 2024

Try this way...

<% if section.children.count > 0 %>
<%= render sections: section.children, partial: 'sections/list' %>
<% end %>

from cache_digests.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.