Q:

Rails 3 - Ancestry gem method arrange not working

hi people
I've follow this tutorial: http://railscasts.com/episodes/262-trees-with-ancestry 
when I tried to make the "arrange (:order => :id)" I got this message
    undefined method `arrange' for #<Array:0x8c19780>

Extracted source (around line #4):

1: 
2: <h1>Listing categories</h1>
3: 
4: <%= nested_categories @categories.arrange(:order => :id) %>
5: 
6: <br />
7:

Can you help me, please? 
Thanks!  

A:

I'm using the ancestry Gem , and it works fine for me.  e.g.:
 require 'awesome_print'                  # just for nice demo output
 ap  Account.arrange(:order => :id) ; 1   

You need to run it on your Categories class itself -- it's a class method
try it out in the Rails console! 

A:

I'll clarify @Tilo's answer:
In your Controller, do:
def index
  @categories = Category.arrange(:order => :created_at)

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @categories }
  end
end

And in your View, do:
<%= nested_categories @categories %>

I'm using Rails 3, and the "Ancestry" gem seems like a great replacement for the "Acts As Tree" gem. 