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
38 39 40 |
# File 'app/models/topic.rb', line 38 def body sb_posts.first end |
#editable_by?(user) ⇒ Boolean
56 57 58 |
# File 'app/models/topic.rb', line 56 def editable_by?(user) user && (user.id == user_id || user.admin? || user.moderator_of?(forum_id)) end |
#hit! ⇒ Object
42 43 44 |
# File 'app/models/topic.rb', line 42 def hit! self.class.increment_counter :hits, id end |
#last_page ⇒ Object
52 53 54 |
# File 'app/models/topic.rb', line 52 def last_page (sb_posts_count.to_f / 25.0).ceil.to_i end |
#notify_of_new_post(post) ⇒ Object
24 25 26 27 28 |
# File 'app/models/topic.rb', line 24 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
50 |
# File 'app/models/topic.rb', line 50 def paged?() sb_posts_count > 25 end |
#sticky? ⇒ Boolean
46 |
# File 'app/models/topic.rb', line 46 def sticky?() sticky == 1 end |
#to_param ⇒ Object
30 31 32 |
# File 'app/models/topic.rb', line 30 def to_param id.to_s << "-" << (title ? title.parameterize : '' ) end |
#views ⇒ Object
48 |
# File 'app/models/topic.rb', line 48 def views() hits end |
#voices ⇒ Object
34 35 36 |
# File 'app/models/topic.rb', line 34 def voices sb_posts.map { |p| p.user_id }.uniq.size end |