File tree Expand file tree Collapse file tree 5 files changed +17
-7
lines changed Expand file tree Collapse file tree 5 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,6 @@ def create
2121 @comment = @protip . comments . build ( create_comment_params )
2222
2323 @comment . user = current_user
24- @comment . user_name = current_user . name
25- @comment . user_email = current_user . email
26- @comment . user_agent = request . user_agent
27- @comment . user_ip = request . remote_ip
2824 @comment . request_format = request . format . to_s
2925
3026 if @comment . save
Original file line number Diff line number Diff line change 1717
1818class Comment < ActiveRecord ::Base
1919 include ActsAsCommentable ::Comment
20+ include AuthorDetails
2021 include SpamFilter
2122
2223 belongs_to :commentable , polymorphic : true
Original file line number Diff line number Diff line change 1+ module AuthorDetails
2+ extend ActiveSupport ::Concern
3+
4+ included do
5+ before_save do
6+ self . user_name = user . name
7+ self . user_email = user . email
8+ self . user_agent = user . last_ua
9+ self . user_ip = user . last_ip
10+ end
11+ end
12+
13+ end
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ module SpamFilter
22 extend ActiveSupport ::Concern
33
44 included do
5- after_save :analyze_spam
65 has_one :spam_report , as : :spammable
76 include Rakismet ::Model
87
@@ -13,9 +12,9 @@ module SpamFilter
1312 user_ip : :remote_ip ,
1413 user_agent : :user_agent
1514
16- def analyze_spam
15+ after_save do
1716 AnalyzeSpamJob . perform_async ( { id : id , klass : self . class . name } )
18- end
17+ end
1918
2019 end
2120end
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ class Protip < ActiveRecord::Base
4343 acts_as_commentable
4444
4545 include ProtipMapping
46+ include AuthorDetails
4647 include SpamFilter
4748
4849 paginates_per ( PAGESIZE = 18 )
You can’t perform that action at this time.
0 commit comments