improved search methods
This commit is contained in:
@@ -14,6 +14,17 @@ class CommentVote < ActiveRecord::Base
|
||||
destroy_all("created_at < ?", 14.days.ago)
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = scoped
|
||||
return q if params.blank?
|
||||
|
||||
if params[:comment_id]
|
||||
q = q.where("comment_id = ?", params[:comment_id].to_i)
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
|
||||
def validate_user_can_vote
|
||||
if !user.can_comment_vote?
|
||||
errors.add :user, "can not comment vote"
|
||||
|
||||
Reference in New Issue
Block a user