title: Why am I getting a "SystemStackError: stack level too deep" in my rails3 beta4 model
body: <p>I'm getting the following error: <code>SystemStackError: stack level too deep</code> when executing the following code in <code>rails3 beta4</code> under <code>ruby 1.9.2-rc1</code>:</p>
  
  <pre><code>ruby-1.9.2-rc1 &gt; f = Forum.all.first
    =&gt; #&lt;Forum id: 1, title: "Forum 1", description: "Description 1", content: "Content 1", parent_id: nil, user_id: 1, forum_type: "forum", created_at: "2010-07-17 04:39:41", updated_at: "2010-07-17 04:39:41", icon_file_name: nil, icon_content_type: nil, icon_file_size: nil, icon_updated_at: nil&gt; 
  ruby-1.9.2-rc1 &gt; f.children
    =&gt; [#&lt;Forum id: 2, title: "Thread 2", description: "Description 2", content: "Content 2", parent_id: 1, user_id: 1, forum_type: "thread", created_at: "2010-07-17 04:40:17", updated_at: "2010-07-17 04:40:17", icon_file_name: nil, icon_content_type: nil, icon_file_size: nil, icon_updated_at: nil&gt;] 
  ruby-1.9.2-rc1 &gt; f.forum_type = "thread"
    =&gt; "thread" 
  ruby-1.9.2-rc1 &gt; f.save
  SystemStackError: stack level too deep
  from /Users/emilkampp/.rvm/rubies/ruby-1.9.2-rc1/lib/ruby/1.9.1/irb/workspace.rb:80
  Maybe IRB bug!!
  ruby-1.9.2-rc1 &gt; 
  </code></pre>
  
  <p>And that is caused by the following code:</p>
  
  <pre><code># Before and after filters
  # 
  before_update :update_all_nested_objects, :if =&gt; :forum_type_changed?
  
  protected
    # Checks if the +forum_type+ has been changed
    # 
    def forum_type_changed?
      self.forum_type_changed?
    end
  
    # Updates all nested upjects if the +forum_type+ has been changed
    # 
    # This will trigger the +update_all_nested_objects+ method on all touched children, thus 
    # starting a chain-reaction all the way through the forum-tree.
    # 
    # NOTE: This is where the error is triggered, since this is the only non-tested looping code, and my test-
    #       cases hasn't changed since this was added.
    # 
    def update_all_nested_objects
      children.each do |child|
        child.forum_type = child_type
        child.save
      end
    end
  </code></pre>
  
  <p>So, what's going on. I have been checking around a little, but nobody seems to have the same problem. Either it's not the same ruby version, thus the workflow.rb file is different, or the <code>stack level to deep</code> is caused by something else.</p>
  
  <p>Any help will be greatly apreciated!</p>
  
  <p>Best regards</p>
  
  <p>// Emil</p>