| Class | Category |
| In: |
app/models/category.rb
|
| Parent: | ActiveRecord::Base |
Finds all top level categories for a given environment.
# 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
# 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
# File app/models/category.rb, line 41
41: def most_commented_articles(limit = 10)
42: self.articles.most_commented(limit)
43: end
# File app/models/category.rb, line 33
33: def recent_articles(limit = 10)
34: self.articles.recent(limit)
35: end
# 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