diff --git a/app/models/category.rb b/app/models/category.rb index 1c251e3..5fd5339 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -54,12 +54,19 @@ class Category < ActiveRecord::Base end def display_in_menu? - if ENV['RAILS_ENV'] == 'development' - return true + display_in_menu + end + + def children_for_menu + results = [] + pending = children.find(:all, :conditions => { :display_in_menu => true}) + while !pending.empty? + cat = pending.shift + results << cat + pending += cat.children.find(:all, :conditions => { :display_in_menu => true} ) end - # FIXME don't hardcode like this. Should be a setting of the environment, maybe - total_items >= 10 + results end end diff --git a/app/views/shared/categories_menu.rhtml b/app/views/shared/categories_menu.rhtml index a79b10c..b9c41b4 100644 --- a/app/views/shared/categories_menu.rhtml +++ b/app/views/shared/categories_menu.rhtml @@ -4,7 +4,7 @@
  • > <%= item.name %>