Re: [ruby-72] Still need some RoR help

From: user 3193291
Sent on: Wednesday, October 31, 2007 6:00 PM
might be cleaner to just to use a partial and recurse with that instead...

On 10/31/07, Paul <[address removed]> wrote:
> On Wed, 31 Oct 2007, Anthony wrote:
> > I do have some issues walking an acts_as_tree object to produce a
> > nested <ul> list...with an unlimited level of nesting.
>
> Never used it, but it sounds like it's a fairly simple recursive
> algorithm.
>
> def display_level(obj)
>    output = "<ul>\n"
>    obj.children.each() do | child |
>      output += "<li>" + child.to_s + "</li>\n"
>      if child.children.lengt­h > 0
>      output += display_level(child)­
>    end
>    output += "</ul>\n"
> end
>
> <%= display_level(root) %>
>
> No?
>
> ...Paul
>
>              ** ...Paul, [address removed], Insane Engineer **
>       ** Visit Project Galactic Guide http://www.galact...­ **
>                 If it's not the same, it should be different.
>
>
>
>
> --
> Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
> This message was sent by Paul ([address removed]) from Silicon Valley Ruby on Rails.
> To learn more about Paul, visit his/her member profile: http://ruby.meetu...­
> To unsubscribe or to update your mailing list settings, click here: http://www.meetup...­
>
> Meetup.com Customer Service: [address removed]
> 632 Broadway New York NY 10012 USA
>
>

Our Sponsors

Perks

People in this
Meetup are also in:

Log in

Not registered with us yet?

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy