mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
work around odd scoping bug in Rails
This commit is contained in:
parent
05a3c8090f
commit
1649f56529
1 changed files with 7 additions and 0 deletions
|
@ -114,12 +114,19 @@ class Search
|
||||||
end
|
end
|
||||||
|
|
||||||
def category_search
|
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)
|
categories = Category.includes(:category_search_data)
|
||||||
.where("category_search_data.search_data @@ #{ts_query}")
|
.where("category_search_data.search_data @@ #{ts_query}")
|
||||||
.references(:category_search_data)
|
.references(:category_search_data)
|
||||||
.order("topics_month DESC")
|
.order("topics_month DESC")
|
||||||
.secured(@guardian)
|
.secured(@guardian)
|
||||||
.limit(@limit)
|
.limit(@limit)
|
||||||
|
.to_a
|
||||||
|
|
||||||
categories.each do |c|
|
categories.each do |c|
|
||||||
@results.add_result(SearchResult.from_category(c))
|
@results.add_result(SearchResult.from_category(c))
|
||||||
|
|
Loading…
Reference in a new issue