How do you loop through and print a multidimensional array in a Rails view?
I'm using the ancestry gem, and would like to print out an entire tree
into a table. The object I'm working with is groups, so it'd look
something like this.
Group A
|__ Group A 1
|__ Group A 1 A
|__ Group A 2
|__ Group A 2 A
|__ Group A 2 B
Group B
Group C
|__ Group C 1
Typically, I'd create a method and call itself within the loop, but that
would seem to break MVC convention. Within the view, how would I output
the object/hash?
Note: Ancestry has a method to convert the ActiveModel group to a hash, so
that is an option rather than iterating through the ActiveModel object
itself.
No comments:
Post a Comment