Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stack level too deep in activesupport callbacks

I am getting the SystemStackError in a Rails 3 app.

All the information I have is useless one line of a stacktrace (taken from the log):

SystemStackError (stack level too deep):
  activesupport (3.2.3) lib/active_support/callbacks.rb:409

So the question is how do I see the full stack trace?

NOTE: I don't care about why this happens, all I want is to see is where it happens.

Using: Rails 3.2.3, Unicorn.

Thanks.

like image 855
Dmytrii Nagirniak Avatar asked May 03 '12 01:05

Dmytrii Nagirniak


1 Answers

If you update an active record in it's before_save or after_save, it will keep on looping.... Also, if you have validates_associated on both ends of an association.

Here is an example of how a before_save callback can create a loop:

class Foo < ActiveRecord::Base
  def before_save
    self.update_attribute(:bar, 'badidea')
  end
end
like image 107
Andrew Kuklewicz Avatar answered Oct 12 '22 00:10

Andrew Kuklewicz