@@ -10,17 +10,15 @@ def index
10
10
@comments = Comment . where ( 'created_at > ?' , 1 . day . ago )
11
11
end
12
12
13
- def new
13
+ def new ; end
14
14
15
- end
16
-
17
- def edit
18
-
19
- end
15
+ def edit ; end
20
16
21
17
def create
22
- redirect_to_signup_if_unauthenticated ( request . referer + "?" + ( params [ :comment ] . try ( :to_query ) || "" ) , "You must signin/signup to add a comment" ) do
23
- @comment = @protip . comments . build ( params [ :comment ] )
18
+ create_comment_params = params . require ( :comment ) . permit ( :comment )
19
+
20
+ redirect_to_signup_if_unauthenticated ( request . referer + "?" + ( create_comment_params . try ( :to_query ) || "" ) , "You must signin/signup to add a comment" ) do
21
+ @comment = @protip . comments . build ( create_comment_params )
24
22
@comment . user = current_user
25
23
respond_to do |format |
26
24
if @comment . save
@@ -36,8 +34,10 @@ def create
36
34
end
37
35
38
36
def update
37
+ update_comment_params = params . require ( :comment ) . permit ( :comment )
38
+
39
39
respond_to do |format |
40
- if @comment . update_attributes ( params [ :comment ] )
40
+ if @comment . update_attributes ( update_comment_params )
41
41
format . html { redirect_to protip_path ( @comment . commentable . try ( :public_id ) ) }
42
42
format . json { head :ok }
43
43
else
@@ -50,7 +50,6 @@ def update
50
50
def destroy
51
51
return head ( :forbidden ) if @comment . nil?
52
52
@comment . destroy
53
- #record_event('destroyed comment')
54
53
respond_to do |format |
55
54
format . html { redirect_to @protip }
56
55
format . json { head :ok }
@@ -68,17 +67,20 @@ def like
68
67
end
69
68
70
69
private
70
+
71
71
def lookup_comment
72
- @comment = Comment . find ( params [ :id ] )
72
+ id = params . permit ( :id ) [ :id ]
73
+ @comment = Comment . find ( id )
73
74
lookup_protip
74
75
end
75
76
76
77
def lookup_protip
77
- @protip = Protip . with_public_id ( params [ :protip_id ] )
78
+ protip_id = params . permit ( :protip_id ) [ :protip_id ]
79
+ @protip = Protip . with_public_id ( protip_id )
78
80
end
79
81
80
82
def verify_ownership
81
83
lookup_comment
82
84
redirect_to ( root_url ) unless ( is_admin? or ( @comment && @comment . authored_by? ( current_user ) ) )
83
85
end
84
- end
86
+ end
0 commit comments