Class: Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Comment
- Includes:
- Gravtastic
- Defined in:
- app/models/comment.rb
Instance Method Summary collapse
- #akismet_attributes ⇒ Object
- #anonymous? ⇒ Boolean
- #author ⇒ Object
- #author_url ⇒ Object
- #check_for_spam ⇒ Object
- #email ⇒ Object
- #email_post_author ⇒ Object
- #mark_as_ham! ⇒ Object
- #mark_as_spam! ⇒ Object
- #request=(request) ⇒ Object
- #set_parent_delta ⇒ Object
Instance Method Details
#akismet_attributes ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/models/comment.rb', line 56 def { :key => '4a8bfe691b69', :blog => "http://#{DOMAIN}", :user_ip => user_ip, :user_agent => user_agent, :comment_author => , :comment_author_email => email, :comment_author_url => , :comment_content => body } end |
#anonymous? ⇒ Boolean
27 28 29 |
# File 'app/models/comment.rb', line 27 def anonymous? !user_id? end |
#author ⇒ Object
35 36 37 |
# File 'app/models/comment.rb', line 35 def user_id.blank? ? : user.to_s end |
#author_url ⇒ Object
39 40 41 |
# File 'app/models/comment.rb', line 39 def anonymous? ? read_attribute(:author_url) : user.url end |
#check_for_spam ⇒ Object
51 52 53 54 |
# File 'app/models/comment.rb', line 51 def check_for_spam self.approved = !Akismetor.spam?() true # return true so it doesn't stop save end |
#email ⇒ Object
31 32 33 |
# File 'app/models/comment.rb', line 31 def email user_id.blank? ? : user.email end |
#email_post_author ⇒ Object
23 24 25 |
# File 'app/models/comment.rb', line 23 def Notifier.deliver_new_comment_alert(self) unless user_id == post.user_id end |
#mark_as_ham! ⇒ Object
74 75 76 77 |
# File 'app/models/comment.rb', line 74 def mark_as_ham! update_attribute(:approved, true) Akismetor.submit_ham() end |
#mark_as_spam! ⇒ Object
69 70 71 72 |
# File 'app/models/comment.rb', line 69 def mark_as_spam! update_attribute(:approved, false) Akismetor.submit_spam() end |
#request=(request) ⇒ Object
45 46 47 48 49 |
# File 'app/models/comment.rb', line 45 def request=(request) self.user_ip = request.remote_ip self.user_agent = request.env['HTTP_USER_AGENT'] self.referrer = request.env['HTTP_REFERER'] end |
#set_parent_delta ⇒ Object
19 20 21 |
# File 'app/models/comment.rb', line 19 def set_parent_delta self.post.update_attributes(:delta => true) end |