Class: Gluttonberg::Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gluttonberg::Comment
- Defined in:
- app/models/gluttonberg/comment.rb
Instance Attribute Summary collapse
-
#blog_slug ⇒ Object
Returns the value of attribute blog_slug.
-
#subscribe_to_comments ⇒ Object
Returns the value of attribute subscribe_to_comments.
Class Method Summary collapse
- .all_comments_count ⇒ Object
- .approved_comments_count ⇒ Object
- .pending_comments_count ⇒ Object
- .rejected_comments_count ⇒ Object
- .spam_comments_count ⇒ Object
- .spam_detection_for_all ⇒ Object
Instance Method Summary collapse
- #approved=(val) ⇒ Object
- #moderate(params) ⇒ Object
- #user_id ⇒ Object
- #user_id=(new_id) ⇒ Object
-
#writer_email ⇒ Object
these are helper methods for comment.
- #writer_name ⇒ Object
Instance Attribute Details
#blog_slug ⇒ Object
Returns the value of attribute blog_slug.
22 23 24 |
# File 'app/models/gluttonberg/comment.rb', line 22 def blog_slug @blog_slug end |
#subscribe_to_comments ⇒ Object
Returns the value of attribute subscribe_to_comments.
22 23 24 |
# File 'app/models/gluttonberg/comment.rb', line 22 def subscribe_to_comments @subscribe_to_comments end |
Class Method Details
.all_comments_count ⇒ Object
44 45 46 |
# File 'app/models/gluttonberg/comment.rb', line 44 def self.all_comments_count self.count end |
.approved_comments_count ⇒ Object
48 49 50 |
# File 'app/models/gluttonberg/comment.rb', line 48 def self.approved_comments_count self.all_approved.count end |
.pending_comments_count ⇒ Object
56 57 58 |
# File 'app/models/gluttonberg/comment.rb', line 56 def self.pending_comments_count self.all_pending.count end |
.rejected_comments_count ⇒ Object
52 53 54 |
# File 'app/models/gluttonberg/comment.rb', line 52 def self.rejected_comments_count self.all_rejected.count end |
.spam_comments_count ⇒ Object
60 61 62 |
# File 'app/models/gluttonberg/comment.rb', line 60 def self.spam_comments_count self.all_spam.count end |
.spam_detection_for_all ⇒ Object
95 96 97 98 99 100 |
# File 'app/models/gluttonberg/comment.rb', line 95 def self.spam_detection_for_all self.all_pending.each do |c| c.send("spam_detection") c.save(:validate => false) end end |
Instance Method Details
#approved=(val) ⇒ Object
90 91 92 93 |
# File 'app/models/gluttonberg/comment.rb', line 90 def approved=(val) @approve_updated = !self.moderation_required && val && self.notification_sent_at.blank? #just got approved write_attribute(:approved, val) end |
#moderate(params) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/gluttonberg/comment.rb', line 29 def moderate(params) if params == "approve" self.moderation_required = false self.approved = true self.spam = false self.save elsif params == "disapprove" self.moderation_required = false self.approved = false self.save else #error end end |
#user_id ⇒ Object
65 66 67 |
# File 'app/models/gluttonberg/comment.rb', line 65 def user_id self. end |
#user_id=(new_id) ⇒ Object
69 70 71 |
# File 'app/models/gluttonberg/comment.rb', line 69 def user_id=(new_id) self.=new_id end |
#writer_email ⇒ Object
these are helper methods for comment.
74 75 76 77 78 79 80 |
# File 'app/models/gluttonberg/comment.rb', line 74 def writer_email if self. self. elsif .email end end |
#writer_name ⇒ Object
82 83 84 85 86 87 88 |
# File 'app/models/gluttonberg/comment.rb', line 82 def writer_name if self. self. elsif .name end end |