File tree 5 files changed +17
-7
lines changed
5 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,6 @@ def create
21
21
@comment = @protip . comments . build ( create_comment_params )
22
22
23
23
@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
28
24
@comment . request_format = request . format . to_s
29
25
30
26
if @comment . save
Original file line number Diff line number Diff line change 17
17
18
18
class Comment < ActiveRecord ::Base
19
19
include ActsAsCommentable ::Comment
20
+ include AuthorDetails
20
21
include SpamFilter
21
22
22
23
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
2
2
extend ActiveSupport ::Concern
3
3
4
4
included do
5
- after_save :analyze_spam
6
5
has_one :spam_report , as : :spammable
7
6
include Rakismet ::Model
8
7
@@ -13,9 +12,9 @@ module SpamFilter
13
12
user_ip : :remote_ip ,
14
13
user_agent : :user_agent
15
14
16
- def analyze_spam
15
+ after_save do
17
16
AnalyzeSpamJob . perform_async ( { id : id , klass : self . class . name } )
18
- end
17
+ end
19
18
20
19
end
21
20
end
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ class Protip < ActiveRecord::Base
43
43
acts_as_commentable
44
44
45
45
include ProtipMapping
46
+ include AuthorDetails
46
47
include SpamFilter
47
48
48
49
paginates_per ( PAGESIZE = 18 )
You can’t perform that action at this time.
0 commit comments