From 096f1be22ba169fa74538bf7bbc40dfc36d65d92 Mon Sep 17 00:00:00 2001 From: albert Date: Sat, 23 Feb 2013 13:27:18 -0500 Subject: [PATCH] fixes #563 --- app/controllers/tags_controller.rb | 3 +-- app/models/artist.rb | 2 +- app/models/tag.rb | 16 ++++++++-------- app/models/wiki_page.rb | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index c5a5c740a..942a14ae0 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -8,8 +8,7 @@ class TagsController < ApplicationController end def index - @search = Tag.search(params[:search]) - @tags = @search.paginate(params[:page]) + @tags = Tag.search(params[:search]).paginate(params[:page]) respond_with(@tags) end diff --git a/app/models/artist.rb b/app/models/artist.rb index 75f472737..375e974b4 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -228,7 +228,7 @@ class Artist < ActiveRecord::Base def search(params) q = active - return q if params.blank? + params = {} if params.blank? case params[:name] when /^http/ diff --git a/app/models/tag.rb b/app/models/tag.rb index 89f5c23c7..420d27f32 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -403,7 +403,7 @@ class Tag < ActiveRecord::Base def search(params) q = scoped - return q if params.blank? + params = {} if params.blank? if params[:name_matches].present? q = q.name_matches(params[:name_matches]) @@ -413,7 +413,7 @@ class Tag < ActiveRecord::Base q = q.where("category = ?", params[:category]) end - if params[:hide_empty] != "no" + if params[:hide_empty].blank? || params[:hide_empty] != "no" q = q.where("post_count > 0") end @@ -422,22 +422,22 @@ class Tag < ActiveRecord::Base end case params[:order] - when "date" - q = q.order("created_at desc") + when "name" + q = q.order("name") else - q = q.order("name") + q = q.order("created_at desc") end case params[:sort] when "count" q = q.order("post_count desc") - when "date" - q = q.order("created_at desc") + when "name" + q = q.order("name") else - q = q.order("name") + q = q.order("created_at desc") end q diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 3183333d2..2c9c68ecc 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -26,7 +26,7 @@ class WikiPage < ActiveRecord::Base def search(params = {}) q = scoped - return q if params.blank? + params = {} if params.blank? if params[:title].present? q = q.where("title LIKE ? ESCAPE E'\\\\'", params[:title].downcase.tr(" ", "_").to_escaped_for_sql_like)