Class: TopicCategory
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TopicCategory
- Defined in:
- app/models/topic_category.rb
Instance Method Summary collapse
- #link ⇒ Object
- #read_visibility ⇒ Object
- #recent_threads(user, count) ⇒ Object
- #update_url ⇒ Object
- #write_visibility ⇒ Object
Instance Method Details
#link ⇒ Object
13 14 15 |
# File 'app/models/topic_category.rb', line 13 def link "/forums/category/#{self.url}" end |
#read_visibility ⇒ Object
17 18 19 |
# File 'app/models/topic_category.rb', line 17 def read_visibility Topic.visibility(self.read_access_level) end |
#recent_threads(user, count) ⇒ Object
25 26 27 28 29 |
# File 'app/models/topic_category.rb', line 25 def recent_threads(user, count) read_level = user ? user.forum_level : 0 self.topic_threads.limit(count).order("topic_threads.id desc").where("topic_threads.is_visible = 1").includes(:topic).where("topics.read_access_level <= #{read_level}") end |
#update_url ⇒ Object
9 10 11 |
# File 'app/models/topic_category.rb', line 9 def update_url self.url = self.name.urlise end |
#write_visibility ⇒ Object
21 22 23 |
# File 'app/models/topic_category.rb', line 21 def write_visibility Topic.visibility(self.write_access_level) end |