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
-
.create_comment(object, session) ⇒ Object
Comment/uncomment this to turn off/on moderation before_save :approve.
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
.create_comment(object, session) ⇒ Object
Comment/uncomment this to turn off/on moderation before_save :approve
20 21 22 |
# File 'lib/forge/app/models/comment.rb', line 20 def self.create_comment(object, session) session.blank? ? Comment.new(:commentable_type => object.class.to_s, :commentable_id => object.id) : Comment.new(session) end |
Instance Method Details
#approve ⇒ Object
38 39 40 |
# File 'lib/forge/app/models/comment.rb', line 38 def approve self.approved = true end |
#approve! ⇒ Object
28 29 30 31 |
# File 'lib/forge/app/models/comment.rb', line 28 def approve! self.approved = true return self.save end |
#author_url ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/forge/app/models/comment.rb', line 42 def if super.blank? || super.match('http://') || super.match('https://') return super else return 'http://' + super end end |
#email ⇒ Object
24 25 26 |
# File 'lib/forge/app/models/comment.rb', line 24 def email self. end |
#error_message ⇒ Object
58 59 60 61 62 |
# File 'lib/forge/app/models/comment.rb', line 58 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
50 51 52 |
# File 'lib/forge/app/models/comment.rb', line 50 def short? content.length > 100 ? true : false end |
#short_comment ⇒ Object
54 55 56 |
# File 'lib/forge/app/models/comment.rb', line 54 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
33 34 35 36 |
# File 'lib/forge/app/models/comment.rb', line 33 def unapprove! self.approved = false return self.save end |