My database is set up as Categories > Things associated by
category_id and has_many and belongs_to.
How would I go about listing all the categories and under each
Category is it’s children? Is there an easy rails way to do this -
without using acts as tree? Any help is appreciated - thanks!
Can you describe your models and what you want to achieve
more clearly ?
From what I understand, you’ve got Category has_many :things
and Thing belongs_to :category .
So you can retrieve your categories and preload their children
@categories = Category.find :all, :include => :things
in the view, iterate on categories and each time, use category.things
Or when you’re speaking of acts_as_tree, do you imply
that Category is a self-referencing model (has_many :subcategories,
:class_name => ‘Category’, :foreign_key => ‘parent_id’ …) ?
and you want to display subcategories ?