Fix comment vote search filtering

This commit is contained in:
Kira 2019-07-22 11:52:42 -07:00
parent 244356d723
commit 84ba528cff
2 changed files with 7 additions and 3 deletions

View File

@ -53,7 +53,7 @@ class CommentVote < ApplicationRecord
end
module SearchMethods
def self.search(params)
def search(params)
q = super
if params[:comment_id].present?
@ -65,6 +65,10 @@ class CommentVote < ApplicationRecord
q = q.where('user_id = ?', user_id) if user_id
end
if params[:user_id].present?
q = q.where('user_id = ?', params[:user_id].to_i)
end
q.order(id: :desc)
q

View File

@ -43,9 +43,9 @@
<% elsif vote.score == nil %>Unrecorded
<% else %><span class='redtext'>Down</span>
<% end %></td>
<td title="Created at <%= vote.created_at.strftime("%c") %>"><%= time_ago_in_words(vote.created_at) %>ago
<td title="Created at <%= vote.created_at.strftime("%c") %>"><%= time_ago_in_words(vote.created_at) %> ago
</td>
<td title="Updated at <%= vote.updated_at.strftime("%c") %>"><%= time_ago_in_words(vote.updated_at) %>ago
<td title="Updated at <%= vote.updated_at.strftime("%c") %>"><%= time_ago_in_words(vote.updated_at) %> ago
</td>
<td><%= link_to_ip vote.user_ip_addr %></td>
</tr>