Class: Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Comment
- Defined in:
- lib/forge/app/models/comment.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#subscribe ⇒ Object
Returns the value of attribute subscribe.
Class Method Summary collapse
Instance Method Summary collapse
- #approve ⇒ Object
- #approve! ⇒ Object
- #author_url ⇒ Object
- #email ⇒ Object
- #error_message ⇒ Object
- #short? ⇒ Boolean
- #short_comment ⇒ Object
-
#spam? ⇒ Boolean
TODO: put this back in has_rakismet.
- #unapprove! ⇒ Object
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
12 13 14 |
# File 'lib/forge/app/models/comment.rb', line 12 def controller @controller end |
#subscribe ⇒ Object
Returns the value of attribute subscribe.
12 13 14 |
# File 'lib/forge/app/models/comment.rb', line 12 def subscribe @subscribe end |
Class Method Details
Instance Method Details
#approve ⇒ Object
43 44 45 |
# File 'lib/forge/app/models/comment.rb', line 43 def approve self.approved = true end |
#approve! ⇒ Object
33 34 35 36 |
# File 'lib/forge/app/models/comment.rb', line 33 def approve! self.approved = true return self.save end |
#author_url ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/forge/app/models/comment.rb', line 47 def if super.blank? || super.match('http://') || super.match('https://') return super else return 'http://' + super end end |
#email ⇒ Object
29 30 31 |
# File 'lib/forge/app/models/comment.rb', line 29 def email self. end |
#error_message ⇒ Object
63 64 65 66 67 |
# File 'lib/forge/app/models/comment.rb', line 63 def errors = [] self.errors..each { |error| errors << "<li>#{error}</li>" } return "<div class='errorExplanation' id='errorExplanation'>There were problems with the following fields:<ul>#{errors}<ul></div>" end |
#short? ⇒ Boolean
55 56 57 |
# File 'lib/forge/app/models/comment.rb', line 55 def short? content.length > 100 ? true : false end |
#short_comment ⇒ Object
59 60 61 |
# File 'lib/forge/app/models/comment.rb', line 59 def short_comment "#{self.content[0..100]}..." end |
#spam? ⇒ Boolean
TODO: put this back in has_rakismet
4 |
# File 'lib/forge/app/models/comment.rb', line 4 def spam?; false; end |
#unapprove! ⇒ Object
38 39 40 41 |
# File 'lib/forge/app/models/comment.rb', line 38 def unapprove! self.approved = false return self.save end |