Class: MongoidForums::Alert

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::DateHelper, Mongoid::Document, Mongoid::Timestamps
Defined in:
app/models/mongoid_forums/alert.rb

Instance Method Summary collapse

Instance Method Details


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/models/mongoid_forums/alert.rb', line 48

def link
  str = ""
  case self.subscription.subscribable_type
  when "MongoidForums::Topic"
    str += "/forums/"
    if self.mongoid_forums_topic_post == nil
      str += "topics/" + self.subscription.subscribable.id.to_s
    else
      str += "posts/" + self.mongoid_forums_topic_post_id.to_s
    end
  else
    str
  end
  str
end

#textObject


64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/mongoid_forums/alert.rb', line 64

def text
  str = ""
  case self.subscription.subscribable_type
    when "MongoidForums::Topic"
      str += self.mongoid_forums_topic_replier
      if self.mongoid_forums_topic_count > 0
        str += " and " + self.mongoid_forums_topic_count.to_s + " other" + (self.mongoid_forums_topic_count > 1 ? "s" : "")
      end
      str += " replied to " + self.subscription.subscribable.name
    else
      str
    end
  return str
end