refactors debate search

This commit is contained in:
rgarcia
2015-08-15 14:57:04 +02:00
parent ce309f352f
commit 4751954377
2 changed files with 34 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
require 'numeric'
class Debate < ActiveRecord::Base
default_scope { order('created_at DESC') }
apply_simple_captcha
TITLE_LENGTH = Debate.columns.find{|c| c.name == 'title'}.limit
@@ -18,6 +20,14 @@ class Debate < ActiveRecord::Base
before_validation :sanitize_description
before_validation :sanitize_tag_list
def self.search(params)
if params[:tag]
tagged_with(params[:tag])
else
all
end
end
def likes
get_likes.size
end