Class: TopicCategory

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/topic_category.rb

Instance Method Summary collapse

Instance Method Details



13
14
15
# File 'app/models/topic_category.rb', line 13

def link
  "/forums/category/#{self.url}"
end

#read_visibilityObject



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_urlObject



9
10
11
# File 'app/models/topic_category.rb', line 9

def update_url
  self.url = self.name.urlise
end

#write_visibilityObject



21
22
23
# File 'app/models/topic_category.rb', line 21

def write_visibility
  Topic.visibility(self.write_access_level)
end