From 05eff38f34b532ec102cd67ee13c9b1cafee12c0 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Sat, 20 Sep 2014 12:57:16 +1000 Subject: [PATCH] FEATURE: add name and username to search within topic --- lib/search.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/search.rb b/lib/search.rb index 2d14b4c997e..c1267d8c080 100644 --- a/lib/search.rb +++ b/lib/search.rb @@ -255,7 +255,8 @@ class Search .where("topics.archetype <> ?", Archetype.private_message) if @search_context.present? && @search_context.is_a?(Topic) - posts = posts.where("posts.raw ilike ?", "%#{@term}%") + posts = posts.joins('JOIN users u ON u.id = posts.user_id') + posts = posts.where("posts.raw || ' ' || u.username || ' ' || u.name ilike ?", "%#{@term}%") else posts = posts.where("post_search_data.search_data @@ #{ts_query}") end