title: ActiveModel::Serializer instance variable in class unaccessible in method
body: <p>I have the snippet below in my <code>ActiveModel::Serializer</code>.  It's a recursive method, but I need to add to an array that's returned when the recursion ends.</p>
  
  <p>So, I set an instance variable <code>@rows</code> equal to an empty array <code>[]</code>.  I push onto that array in the method, but Ruby is returning an <code>undefined method 'push' for nil:NilClass</code>.</p>
  
  <pre><code>class MySerializer &lt; ActiveModel::Serializer
    attributes :hierarchies
  
    @rows = []
  
    def hierarchies_run(child, user)
      hierarchy = UserHierarchy.where(child: child, user_id: user).first
  
      if hierarchy
        @rows.push(UserSimpleSerializer.new(User.find(hierarchy.child), :root =&gt; false))
        hierarchies_run(hierarchy.parent, current.id)
      else
        @rows.push(UserSimpleSerializer.new(User.find(child), :root =&gt; false))
      end
    end
  
    def hierarchies
      hierarchies_run(current.id, current.id)
      @rows
    end
  end
  </code></pre>
  
  <p>Why is it returning this error?</p>