SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to create a collection of collections?

    Hi

    I'm using awesome nested set to return ancestors and self_and_siblings from a tree database structure. I would like to create an object of those both, pass to a partial which iterates over the ancestors (2 * UL's) and passes to another partial which iterates over the siblings (x * LI's).

    Basically how do i do this:

    @collection.ancestors = Nutrient.find(params[:id]).ancestors
    @collection.siblings = Nutrient.find(params[:id]).self_and_siblings

    I have tried that and:

    @nutrients = {:children => @children, arents => @parents }

    I realise this is probably really simple but I have wasted a good couple of hours on this already and would really appreciate some help. :S

  2. #2
    SitePoint Guru Majglow's Avatar
    Join Date
    Aug 1999
    Location
    B-Town
    Posts
    645
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, I'm pretty confused about what you are asking. What are you exactly having trouble with? What is @collection?

    You could just use locals.

    In the controller:
    Code:
    @nutrient = Nutrient.find(params[:id])
    In the view:
    Code:
    render :partial => "ancestors", :collection => @nutrient.ancestors
    Then in that partial:
    Code:
    render :partial => "siblings", :collection => @nutrient.self_and_siblings
    Ohai!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •