Class Category
In: app/models/category.rb
Parent: ActiveRecord::Base

Methods

Public Class methods

Finds all top level categories for a given environment.

[Source]

    # File app/models/category.rb, line 12
12:   def self.top_level_for(environment)
13:     self.find(:all, :conditions => ['parent_id is null and environment_id = ?', environment.id ])
14:   end

Public Instance methods

[Source]

    # File app/models/category.rb, line 54
54:   def children_for_menu
55:     results = []
56:     pending = children.find(:all, :conditions => { :display_in_menu => true})
57:     while !pending.empty?
58:       cat = pending.shift
59:       results << cat
60:       pending += cat.children.find(:all, :conditions => { :display_in_menu => true} )
61:     end
62: 
63:     results
64:   end

[Source]

    # File app/models/category.rb, line 50
50:   def display_in_menu?
51:     display_in_menu
52:   end

[Source]

    # File app/models/category.rb, line 41
41:   def most_commented_articles(limit = 10)
42:     self.articles.most_commented(limit)
43:   end

[Source]

    # File app/models/category.rb, line 33
33:   def recent_articles(limit = 10)
34:     self.articles.recent(limit)
35:   end

[Source]

    # File app/models/category.rb, line 37
37:   def recent_comments(limit = 10)
38:     comments.find(:all, :order => 'created_at DESC, comments.id DESC', :limit => limit)
39:   end

[Source]

    # File app/models/category.rb, line 45
45:   def total_items
46:     # FIXME this can be SLOW (??)
47:     articles.count + comments.count + enterprises.count + people.count + communities.count + products.count
48:   end

[Validate]