SystemStackError: stack level too deep

1 Min. Read
Aug 14, 2019

 SystemStackError Ruby On Rails Scopes Problem

Background

Today I encountered with the following error. I didn’t know what might be the cause of this error.

Expected Culprit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SystemStackError in DashboardsController#show
stack level too deep

Extracted source (around line #11):

    else
      > @questions = current_organization.questions.in_dashboard
        @subjects  = current_organization.subjects.in_dashboard
    end
  end

Rails.root: /Users/john/projects/lgprofile

Application Trace | Framework Trace | Full Trace
app/controllers/dashboards_controller.rb:11:in `show'

The code in line no#11 looks fine to me. It was n’t changed in a few days. This should not be the cause. I then checked the associations. May be something changed and is causing this error. I found no changes in the model association code.

While going through the git diff I saw some new line in model like

Real Culprit

1
2
  +  scope :parents, -> { where(question_id: nil) }
  +

When I commented this code, the app started running again.

Reason behind this error

You might also like

I got `SystemStackError: stack level too deep` error when defining a named scope in Model.
Read More..


Write To Me

Hire me shiva bhusal
We'll never share your email with anyone else.
I'll never share your email with anyone else.