Skip to content

Commit 16df460

Browse files
committed
fixing issue with admin page
1 parent 24d32c1 commit 16df460

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

app/controllers/comments_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def index
66
format.html {
77
# TODO: do we need this check?
88
return head(:forbidden) unless admin?
9-
@comments = Comment.order(created_at: :desc).page(params[:page])
9+
@comments = Comment.on_protips.order(created_at: :desc).page(params[:page])
1010
}
1111
format.json {
1212
@comments = Comment.

app/models/comment.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Comment < ActiveRecord::Base
1414
validates :body, length: { minimum: 2 }
1515

1616
scope :recently_created, ->(count=10) { order(created_at: :desc).limit(count)}
17+
scope :on_protips, -> { joins(:article).where(protips: {type: 'Protip'}) }
1718

1819
def dom_id
1920
ActionView::RecordIdentifier.dom_id(self)

app/views/comments/index.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.sm-col.sm-col.sm-col-12.md-col-8
55
-@comments.each do |comment|
66
%h6.mt1
7-
=link_to comment.protip.title, protip_path(comment.protip)
7+
=link_to comment.article.title, protip_path(comment.article)
88
=render comment
99
.bold.mb4
1010
=link_to("Delete #{comment.user.username} and their #{comment.user.comments.size} comments", user_path(comment.user), method: :delete, class: 'diminish mr1')

0 commit comments

Comments
 (0)