<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - acts as tree simple menu]]></title>
		<link>http://railsforum.com/viewtopic.php?id=1560</link>
		<description><![CDATA[The most recent posts in acts as tree simple menu.]]></description>
		<lastBuildDate>Thu, 10 Dec 2009 03:56:23 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=114379#p114379</link>
			<description><![CDATA[<p>This tutorial is excellent.</p><p>I&#039;d like to extend Ryan&#039;s code to order the tree by two conditions. The first, would be for each level of the tree to display in alphabetical order. The second condition would be a &quot;sticky&quot; boolean field included in each category that would take priority over the alphabetical order condition.</p><p>So, the output for a life tree would look like this:</p><p>- Animal<br />-- Mammal (sticky field is true)<br />--- Human (sticky field is true)<br />--- Dolphin<br />--- Whale<br />-- Bird<br />-- Dinosaur<br />-- Fish<br />- Plant<br />-- Flower<br />-- Tree<br />--- Oak</p>]]></description>
			<author><![CDATA[dummy@example.com (Uriptical)]]></author>
			<pubDate>Thu, 10 Dec 2009 03:56:23 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=114379#p114379</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=99940#p99940</link>
			<description><![CDATA[<p>HI</p><p>every nice tutorial on acts_as_tree </p><p>am using acts_as_tree and yui to generate tree structure,<br />as per the DB is consern for acts_as_tree,the parent and child nodes are from one table..</p><br /><p>i have two different table like</p><br /><p>region table<br />-------------<br />pk&nbsp; &nbsp; &nbsp;name&nbsp; &nbsp; &nbsp; &nbsp;<br />1&nbsp; &nbsp; &nbsp; hyderabad<br />2&nbsp; &nbsp; &nbsp; chennai<br />3&nbsp; &nbsp; &nbsp; bangalore</p><br /><p>area tabel<br />id&nbsp; &nbsp; &nbsp;name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fk<br />1&nbsp; &nbsp; &nbsp; madhapur&nbsp; &nbsp; &nbsp; 1<br />2&nbsp; &nbsp; &nbsp; hi-tech&nbsp; &nbsp; &nbsp; &nbsp;1<br />3&nbsp; &nbsp; &nbsp; kondapur&nbsp; &nbsp; &nbsp; 1<br />4&nbsp; &nbsp; &nbsp; adayar&nbsp; &nbsp; &nbsp; &nbsp; 2<br />5&nbsp; &nbsp; &nbsp; ECR road&nbsp; &nbsp; &nbsp; 2<br />6&nbsp; &nbsp; &nbsp; anna nagar&nbsp; &nbsp; 2<br />7&nbsp; &nbsp; &nbsp; whitefiled&nbsp; &nbsp; 3<br />8&nbsp; &nbsp; &nbsp; MGM&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3</p><br /><br /><p>so i need name in region table as root node and the respective fk names in area table as child nodes(i dont need subchild node )..</p><br /><br /><p>how can i use acts_as_tree for this table,are is there an alternative to do this</p>]]></description>
			<author><![CDATA[dummy@example.com (mallu_charan)]]></author>
			<pubDate>Sat, 06 Jun 2009 08:27:05 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=99940#p99940</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=87237#p87237</link>
			<description><![CDATA[<p>Hello evebody!<br />It&#039;s a good example. <br />But I can&#039;t create a new subcategory.That&#039;s what I have:<br /><pre name="code" class="ruby:nogutter">A piece of code from the schema:<br />create_table &quot;regional_objects&quot;, :force =&gt; true do |t|<br />&nbsp; &nbsp; t.string&nbsp; &nbsp;&quot;name&quot;<br />&nbsp; &nbsp; t.integer&nbsp; &quot;parent_id&quot;<br />&nbsp; &nbsp; t.datetime &quot;created_at&quot;<br />&nbsp; &nbsp; t.datetime &quot;updated_at&quot;<br />&nbsp; end</pre><br />My model :<br /><pre name="code" class="ruby:nogutter">class RegionalObject &lt; ActiveRecord::Base<br />&nbsp; acts_as_tree :order =&gt; &quot;name&quot;<br />#the rest of associations is deleted just for the example<br />end</pre><br />My &#039;index&#039; page:<br /><pre name="code" class="ruby:nogutter">&lt;% if @regional_objects.empty? %&gt;<br />&nbsp; &lt;h4&gt; No Granting regions found&lt;/h4&gt;<br />&lt;% else %&gt;<br />&nbsp; &lt;h4&gt;Listing Granting regions&lt;/h4&gt;<br />&nbsp; &lt;%= render :partial =&gt; &#039;regional_object&#039;, :collection =&gt; @regional_objects%&gt;<br />&nbsp; <br />&nbsp; &lt;%= will_paginate @regional_objects %&gt;<br />&lt;%end%&gt;<br />&lt;br /&gt;<br />&lt;%= link_to &#039;New granting region&#039;, new_regional_object_path %&gt;</pre><br />My partial (regional_object):<br /><pre name="code" class="ruby:nogutter">&lt;table&gt;<br />&nbsp; &lt;td&gt;&lt;%= h regional_object.name%&gt;&lt;/td&gt;<br />&nbsp; &lt;td&gt;&lt;%= link_to &#039;Sub-Regions&#039;, regional_object%&gt;&lt;/td&gt;<br />&nbsp; &lt;td&gt;&lt;%= link_to &#039;Edit&#039;, edit_regional_object_path(regional_object)%&gt;&lt;/td&gt;<br />&nbsp; &lt;td&gt;&lt;%= link_to &#039;Destroy&#039;, regional_object, :confirm =&gt; &#039;Are you sure?&#039;, :method =&gt; :delete%&gt;&lt;/td&gt;<br />&lt;/table&gt;</pre><br />My &#039;show&#039; page:<br /><pre name="code" class="ruby:nogutter">&lt;p&gt;<br />&nbsp; &lt;b&gt;Name:&lt;/b&gt;<br />&nbsp; &lt;%=h @regional_object.name %&gt;<br />&lt;/p&gt;<br />&lt;%if @regional_object.children.empty?%&gt;<br />&nbsp; &lt;h4&gt;No sub regions found&lt;/h4&gt;<br />&lt;%else%&gt;<br />&nbsp; &lt;%= render :partial =&gt; &#039;regional_object&#039;, :collection =&gt; @regional_object.children %&gt;<br />&lt;%end%&gt;<br />&lt;br/&gt;<br />&lt;%= link_to &#039;Add&#039;, new_regional_object_path%&gt;|<br />&lt;%= link_to &#039;Back&#039;, regional_objects_path %&gt;</pre><br />My &#039;new&#039; page:<br /><pre name="code" class="ruby:nogutter">&lt;% form_for @regional_object do |form| %&gt;<br />&nbsp; &lt;%= form.error_messages %&gt;<br />&nbsp; &lt;h1&gt;Create a Sub-Region for &lt;%=h @regional_object.parent.name%&gt;&lt;/h1&gt;<br />&nbsp; &lt;p&gt;<br />&nbsp; &nbsp; &lt;%= form.label :name, &quot;Sub-Region&quot; %&gt;&lt;br /&gt;<br />&nbsp; &nbsp; &lt;%= form.text_field :name %&gt;<br />&nbsp; &lt;/p&gt;<br />&nbsp; &lt;p&gt;<br />&nbsp; &nbsp; &lt;%= submit_tag &quot;Create&quot; %&gt;<br />&nbsp; &lt;/p&gt;</p><p>&lt;% end %&gt;<br />&lt;%= link_to &#039;Back&#039;, @regional_object.parent %&gt;</pre><br />How to get parent_id in my Controller (edit, new, delete and update actions) in this case?<br />Should I change anything in &#039;routes.rb&#039; ? I use the same technics but between models with relations as one-to-many( by the same way I can add one or many &#039;packagings&#039; for a &#039;product&#039; for example. But in this case I have:<br /><pre name="code" class="ruby:nogutter">map.resources :products, :has_many =&gt; :packagings</pre><br />How to get work the acts_as_tree&#039; plugin in my controller?</p>]]></description>
			<author><![CDATA[dummy@example.com (Javix)]]></author>
			<pubDate>Mon, 09 Feb 2009 13:38:35 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=87237#p87237</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=42277#p42277</link>
			<description><![CDATA[<p>I get this error, any idea what I am doing wrong? </p><p>Showing app/views/reporter/_side_nav.rhtml where line #10 raised:</p><p>undefined method `children&#039; for ReportGroup:Class</p><p>Extracted source (around line #10):</p><p>7:&nbsp; &nbsp; &lt;/ul&gt;<br />8: <br />9:&nbsp; &nbsp; &nbsp;&lt;li&gt;&lt;%= link_to ReportGroup.name, {:controller =&gt; &#039;reporter&#039;, :action =&gt; &quot;list_reports&quot;, :id =&gt; ReportGroup.id } %&gt;&lt;/li&gt;<br />10:&nbsp; &nbsp; &nbsp;&lt;% if ReportGroup.children.empty? %&gt;</p><p>db(report_groups)<br /><pre name="code" class="ruby:nogutter">&#039;id&#039;, &#039;int(11)&#039;, &#039;NO&#039;, &#039;PRI&#039;, &#039;&#039;, &#039;auto_increment&#039;<br />&#039;name&#039;, &#039;varchar(255)&#039;, &#039;YES&#039;, &#039;&#039;, &#039;&#039;, &#039;&#039;<br />&#039;parent_id&#039;, &#039;int(11)&#039;, &#039;YES&#039;, &#039;&#039;, &#039;&#039;, &#039;&#039;<br />&#039;position&#039;, &#039;int(11)&#039;, &#039;YES&#039;, &#039;&#039;, &#039;&#039;, &#039;&#039;</pre><br />report_group.rb<br /><pre name="code" class="ruby:nogutter">class ReportGroup &lt; ActiveRecord::Base<br />&nbsp; acts_as_tree :order =&gt; &quot;name&quot; <br />end</pre><br />reporter_controller.rb<br /><pre name="code" class="ruby:nogutter">class ReporterController &lt; ApplicationController</p><p>&nbsp; def index<br />&nbsp; &nbsp; @page_title = &#039;Reporter Dashboard&#039;<br />&nbsp; &nbsp; @statistics = Stat.find(:all, :order =&gt; &quot;name&quot;)<br />&nbsp; &nbsp; @graphs = Graph.find(:all, :order =&gt; &quot;name&quot;)<br />&nbsp; &nbsp; @report_groups = ReportGroup.find:all<br />&nbsp; end</pre><br />views/layouts/reporter.rhtml<br /><pre name="code" class="ruby:nogutter">&lt;% content_for :side_nav do %&gt;<br />&nbsp; &nbsp; &lt;%# TODO: move reporter side_nav in here when it&#039;s considered complete %&gt;<br />&nbsp; &nbsp; &lt;%= render :partial =&gt; &#039;reporter/side_nav&#039; %&gt;<br />&lt;% end %&gt;</p><p>&lt;% session[:layout] = :reporter %&gt;<br />&lt;% inside_layout &#039;application&#039; do %&gt;<br />&nbsp; &nbsp; &lt;%= yield %&gt;<br />&lt;% end %&gt;</pre><br />views/reporter/_side_nav.rhtml<br /><pre name="code" class="ruby:nogutter">&lt;p&gt;<br />&nbsp; Standard Reports</p><p>&nbsp; <br />&nbsp; &nbsp;&lt;ul&gt;<br />&nbsp; &nbsp; &nbsp;&lt;%= render :partial =&gt; &#039;report_group&#039;, :collection =&gt; ReportGroup.find_all_by_parent_id(nil) %&gt;<br />&nbsp; &nbsp;&lt;/ul&gt;</p><p>&nbsp; &nbsp; &lt;li&gt;&lt;%= link_to ReportGroup.name, {:controller =&gt; &#039;reporter&#039;, :action =&gt; &quot;list_reports&quot;, :id =&gt; ReportGroup.id } %&gt;&lt;/li&gt;<br />&nbsp; &nbsp; &lt;% if ReportGroup.children.empty? %&gt;<br />&nbsp; &nbsp; &nbsp; &lt;span&gt; No sub&lt;/span&gt;<br />&nbsp; &nbsp; &nbsp; &lt;% else %&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;ul&gt;&lt;%= render :partial =&gt; &#039;report_group&#039;, :collection =&gt; ReportGroup.children %&gt;&lt;/ul&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;% end %&gt;<br />&nbsp; &nbsp; &nbsp; &lt;ul&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;% ReportGroup.standard_reports.each do |sr| %&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;% if rg.name.downcase == &#039;summary&#039;%&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;%= link_to sr.name, {:controller =&gt; &#039;reporter&#039;, :action =&gt; &#039;show&#039;, :id =&gt; sr.id }%&gt;&lt;/li&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;% end %&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;% end %&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/ul&gt;</p><p>&nbsp; &lt;/ul&gt;<br />&lt;/p&gt;</pre></p>]]></description>
			<author><![CDATA[dummy@example.com (hallikpapa)]]></author>
			<pubDate>Mon, 15 Oct 2007 20:20:48 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=42277#p42277</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=39475#p39475</link>
			<description><![CDATA[<div class="quotebox"><cite>New2RubyOnRails wrote:</cite><blockquote><p>Cool, Thanks ryanb... I assume it is possible to display it in a drop down?</p></blockquote></div><p>Yeah it&#039;s certainly possible, but the difficulty depends on what you want to do (have it sorted properly with indents is kind of hard). I recommend starting a separate thread on this if you need to do this.</p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Tue, 18 Sep 2007 18:44:13 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=39475#p39475</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=39464#p39464</link>
			<description><![CDATA[<p>Cool, Thanks ryanb... I assume it is possible to display it in a drop down?</p><p>Thanks again</p>]]></description>
			<author><![CDATA[dummy@example.com (New2RubyOnRails)]]></author>
			<pubDate>Tue, 18 Sep 2007 17:50:27 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=39464#p39464</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=39442#p39442</link>
			<description><![CDATA[<p>Try renaming the &quot;list&quot; action to &quot;index&quot;.</p><p>Also, looks like you&#039;re using zero as the root parent_id value. In that case the find by &quot;nil&quot; won&#039;t work, you&#039;ll need to either find by &quot;0&quot; or change your table content.</p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Tue, 18 Sep 2007 16:22:23 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=39442#p39442</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=39436#p39436</link>
			<description><![CDATA[<p>Hello, </p><p>Newbie here</p>]]></description>
			<author><![CDATA[dummy@example.com (New2RubyOnRails)]]></author>
			<pubDate>Tue, 18 Sep 2007 15:45:07 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=39436#p39436</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=35846#p35846</link>
			<description><![CDATA[<p>Any idea how to get this tree style into a select menu that will have unlimited levels?</p>]]></description>
			<author><![CDATA[dummy@example.com (chovy)]]></author>
			<pubDate>Sun, 19 Aug 2007 23:23:33 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=35846#p35846</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=28468#p28468</link>
			<description><![CDATA[<p>The recursive partial works great for me. I am ordering my tree using an integer column named position. In my list I want to have an Up/Down command to let me reorder children. So I added up/down links which work. But now I only want to show up/down links when they make sense: i.e., the top child will not show the up link and the bottom child won&#039;t show the down link.</p><p>The top child is easy to do, as I just check item.position == 0. However, the bottom one is trickier. Currently I run a query to check if the position of the item is equal to the max position for that set of children.</p><p>I&#039;m hopeful that there&#039;s some nice Ruby/Rails feature like item.last? that would work for me. If I could access the collection that gets looped in the partial, I could do something like item == collection.last, but I don&#039;t know how to access the collection from the partial.</p><p>Any suggestions?</p>]]></description>
			<author><![CDATA[dummy@example.com (boone)]]></author>
			<pubDate>Sun, 24 Jun 2007 21:10:06 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=28468#p28468</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=28450#p28450</link>
			<description><![CDATA[<p>Ryan,</p><p>Thank you very much for your reply.</p><p>Question 1:<br />-----------<br />Example of my scenario is as follows:</p><br /><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Group-1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ------------------------------------------------------------------------------<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ..&nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;..&nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; ..|<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Group-2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Group-3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Group-4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Group-9<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-------------------------------------------------------&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;User-9&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Group-3.1&nbsp; &nbsp; &nbsp; Group-3.2&nbsp; &nbsp; &nbsp;Group-3.3&nbsp; &nbsp; &nbsp;User-3.1&nbsp; &nbsp; &nbsp;User-3.2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />&nbsp; &nbsp; &nbsp; &nbsp; ----------------<br />&nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />Group-3.1.1&nbsp; &nbsp; &nbsp; &nbsp;Group-3.1.2</p><p>Note:&nbsp; <br />1.&nbsp; Group can have sub-groups.&nbsp; I have Group model with parent_id.<br />2.&nbsp; User is under a group.&nbsp; I have User model with group_id.<br />3.&nbsp; Group/sub-group can have zero or more users.<br />4.&nbsp; The tree above shows that user cannot have sub-group under it.<br />5.&nbsp; I have multiple layers of groups and sub-groups.</p><p>How can I display these 2 models - Group and User in the same tree structure.</p><br /><p>Question 2:<br />-----------<br />Based on the partial code in the earlier post, I tried the following.&nbsp; But, I encountered error saying Nil is encountered in the 2nd line of _group.html:</p><p>Group controller:</p><p>def list<br />&nbsp; @parent_id = ?? # where ?? = id set by other part of the controller<br />&nbsp; @group = Category.find_all_by_parent_id(@parent_id)<br />&nbsp; if @group.empty?<br />&nbsp; &nbsp; #... display NO SEARCH RESULTS<br />&nbsp; end<br />end</p><p>list.rhtml:</p><p>&lt;%= render :partial =&gt; &#039;group&#039;, :collection =&gt; @group %&gt;</p><p>_group.rhtml:</p><p>As per the partial code in the earlier post, where the 2nd line reads as:<br />&nbsp; &lt;%= link_to h(group.name), :controller =&gt; &#039;group&#039;, :action =&gt; &#039;show&#039;, :id =&gt; group.id %&gt;</p>]]></description>
			<author><![CDATA[dummy@example.com (weelkoh0)]]></author>
			<pubDate>Sun, 24 Jun 2007 17:28:59 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=28450#p28450</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=28438#p28438</link>
			<description><![CDATA[<p>If you only need to display one layer of children you may not need to do anything complicated with partials.</p><p><pre name="code" class="ruby:nogutter">&lt;%= @parent_group.name %&gt;<br />&lt;% for group in @parent_group.children %&gt;<br />&nbsp; &lt;%= group.name %&gt;<br />&lt;% end %&gt;<br />&lt;% for user in @parent_group.users %&gt;<br />&nbsp; &lt;%= user.name %&gt;<br />&lt;% end %&gt;</pre></p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Sun, 24 Jun 2007 16:04:56 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=28438#p28438</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=28427#p28427</link>
			<description><![CDATA[<p>Using the &quot;collection&quot; does not display the parent.&nbsp; Is there a way to do this?</p><p>I have 2 models: Group and User.<br />- Group has these fields:&nbsp; id, name, parent_id.<br />- User has these fields:&nbsp; &nbsp;id, name, group_id.</p><p>what I need is:<br />1.&nbsp; User to enter the (parent) group that s/he wants to see.<br />2.&nbsp; I need to display the (parent) group as entered by user, then the children groups, and lastly the users under the (parent) group.</p><p>Thank you very much for your help.</p>]]></description>
			<author><![CDATA[dummy@example.com (weelkoh0)]]></author>
			<pubDate>Sun, 24 Jun 2007 12:22:44 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=28427#p28427</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=28424#p28424</link>
			<description><![CDATA[<p>Interesting tutorial.&nbsp; I learn more about Acts As Tree.</p><p>Regarding the &quot;toggle children&quot; function, pls enlighten me how to write the code to allow toggling of the children records.</p><p>Thank you.</p>]]></description>
			<author><![CDATA[dummy@example.com (weelkoh0)]]></author>
			<pubDate>Sun, 24 Jun 2007 10:59:01 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=28424#p28424</guid>
		</item>
		<item>
			<title><![CDATA[Re: acts as tree simple menu]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=26883#p26883</link>
			<description><![CDATA[<p>Thanks!&nbsp; that fixed it.</p><p>btw, i really enjoy your podcasts!</p>]]></description>
			<author><![CDATA[dummy@example.com (37questions)]]></author>
			<pubDate>Wed, 13 Jun 2007 00:38:12 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=26883#p26883</guid>
		</item>
	</channel>
</rss>
