Topic: Optimize code

Hello, I'am new here and this is my first post smile

I'm trying to optimize my menu with dropdown. It shows forum categories, subcategory, subcategory in subcategory and so on in different levels. All categories are in a database.

My database looks like this:

    create_table :forum_categories do |t|
      t.string  :name, :description
      t.integer :forum_category_id, :default => 0


Here are the Rails code:
[code=]<% lvl3 = ForumCategory.find_all_by_forum_category_id(0) %>
<%= "<li><a>No categories!</a></li>" if lvl3.blank? %>
<% lvl3.each do |lvl3| %>
    <% lvl4 = ForumCategory.find_all_by_forum_category_id( %>
    <li><a href="#a"><%= "<span>

Re: Optimize code

you should use a plugin like  acts_as_nested_set
It allowes you to get all nested child objects with 1 query.

(The doc for it is a couple directories down in the /lib folder, in nested_set.rb)

Re: Optimize code

I don't understand how to use it, I've tried to read the doc. But I don't understand anyway, I even don't know how to install the plugin. script/plugin install … nested_set desn't work.

Please, help.