work around odd scoping bug in Rails

This commit is contained in:
Sam 2013-12-13 19:00:48 +11:00
parent 05a3c8090f
commit 1649f56529
1 changed files with 7 additions and 0 deletions

View File

@ -114,12 +114,19 @@ class Search
end
def category_search
# scope is leaking onto Category, this is not good and probably a bug in Rails
# the secure_category_ids will invoke the same method on User, it calls Category.where
# however the scope from the query below is leaking in to Category, this works around
# the issue while we figure out what is up in Rails
secure_category_ids
categories = Category.includes(:category_search_data)
.where("category_search_data.search_data @@ #{ts_query}")
.references(:category_search_data)
.order("topics_month DESC")
.secured(@guardian)
.limit(@limit)
.to_a
categories.each do |c|
@results.add_result(SearchResult.from_category(c))