ordering an acts_as_tree relationship

Posted by timpone on Stack Overflow See other posts from Stack Overflow or by timpone
Published on 2012-10-04T21:36:14Z Indexed on 2012/10/04 21:37 UTC
Read the original article Hit count: 297

I have a Category class that is defined like this:

class Catergoy < ActiveRecord::Base
  acts_as_tree :parent_id 

I'd like the ordering to be by the position value which is a float such that:

 category-1
   category-2, parent_id=1, position=0.5
     category-3, parent_id=2,
   category-4, parent_id=1, position=1

How would I specify this?

I tried

acts_as_tree :parent_id :order => :position 
acts_as_tree :parent_id, :order => :position 

but these are not working. Any ideas how to specify this relationship? Or if I'm missing something else?

thx in advance

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby-on-rails-3