This commit is contained in:
albert
2013-02-23 13:27:18 -05:00
parent 3c1176b077
commit 096f1be22b
4 changed files with 11 additions and 12 deletions

View File

@@ -8,8 +8,7 @@ class TagsController < ApplicationController
end end
def index def index
@search = Tag.search(params[:search]) @tags = Tag.search(params[:search]).paginate(params[:page])
@tags = @search.paginate(params[:page])
respond_with(@tags) respond_with(@tags)
end end

View File

@@ -228,7 +228,7 @@ class Artist < ActiveRecord::Base
def search(params) def search(params)
q = active q = active
return q if params.blank? params = {} if params.blank?
case params[:name] case params[:name]
when /^http/ when /^http/

View File

@@ -403,7 +403,7 @@ class Tag < ActiveRecord::Base
def search(params) def search(params)
q = scoped q = scoped
return q if params.blank? params = {} if params.blank?
if params[:name_matches].present? if params[:name_matches].present?
q = q.name_matches(params[:name_matches]) q = q.name_matches(params[:name_matches])
@@ -413,7 +413,7 @@ class Tag < ActiveRecord::Base
q = q.where("category = ?", params[:category]) q = q.where("category = ?", params[:category])
end end
if params[:hide_empty] != "no" if params[:hide_empty].blank? || params[:hide_empty] != "no"
q = q.where("post_count > 0") q = q.where("post_count > 0")
end end
@@ -422,22 +422,22 @@ class Tag < ActiveRecord::Base
end end
case params[:order] case params[:order]
when "date" when "name"
q = q.order("created_at desc") q = q.order("name")
else else
q = q.order("name") q = q.order("created_at desc")
end end
case params[:sort] case params[:sort]
when "count" when "count"
q = q.order("post_count desc") q = q.order("post_count desc")
when "date" when "name"
q = q.order("created_at desc") q = q.order("name")
else else
q = q.order("name") q = q.order("created_at desc")
end end
q q

View File

@@ -26,7 +26,7 @@ class WikiPage < ActiveRecord::Base
def search(params = {}) def search(params = {})
q = scoped q = scoped
return q if params.blank? params = {} if params.blank?
if params[:title].present? if params[:title].present?
q = q.where("title LIKE ? ESCAPE E'\\\\'", params[:title].downcase.tr(" ", "_").to_escaped_for_sql_like) q = q.where("title LIKE ? ESCAPE E'\\\\'", params[:title].downcase.tr(" ", "_").to_escaped_for_sql_like)