Class: Topic
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Topic
- Defined in:
- app/models/topic.rb
Instance Method Summary collapse
- #body ⇒ Object
- #editable_by?(user) ⇒ Boolean
- #hit! ⇒ Object
- #last_page ⇒ Object
- #notify_of_new_post(post) ⇒ Object
- #paged? ⇒ Boolean
- #sticky? ⇒ Boolean
- #to_param ⇒ Object
- #views ⇒ Object
- #voices ⇒ Object
Instance Method Details
#body ⇒ Object
37 38 39 |
# File 'app/models/topic.rb', line 37 def body sb_posts.first end |
#editable_by?(user) ⇒ Boolean
55 56 57 |
# File 'app/models/topic.rb', line 55 def editable_by?(user) user && (user.id == user_id || user.admin? || user.moderator_of?(forum_id)) end |
#hit! ⇒ Object
41 42 43 |
# File 'app/models/topic.rb', line 41 def hit! self.class.increment_counter :hits, id end |
#last_page ⇒ Object
51 52 53 |
# File 'app/models/topic.rb', line 51 def last_page (sb_posts_count.to_f / 25.0).ceil.to_i end |
#notify_of_new_post(post) ⇒ Object
23 24 25 26 27 |
# File 'app/models/topic.rb', line 23 def notify_of_new_post(post) monitorships.each do |m| UserNotifier.new_forum_post_notice(m.user, post).deliver if (m.user != post.user) && m.user.notify_comments end end |
#paged? ⇒ Boolean
49 |
# File 'app/models/topic.rb', line 49 def paged?() sb_posts_count > 25 end |
#sticky? ⇒ Boolean
45 |
# File 'app/models/topic.rb', line 45 def sticky?() sticky == 1 end |
#to_param ⇒ Object
29 30 31 |
# File 'app/models/topic.rb', line 29 def to_param id.to_s << "-" << (title ? title.parameterize : '' ) end |
#views ⇒ Object
47 |
# File 'app/models/topic.rb', line 47 def views() hits end |
#voices ⇒ Object
33 34 35 |
# File 'app/models/topic.rb', line 33 def voices sb_posts.map { |p| p.user_id }.uniq.size end |