From 3246f066c68e0e359eb341c2282be20202676478 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 2 Aug 2013 10:31:36 +1000 Subject: [PATCH] an attempt at getting this working on rails 4 ... not fruitful --- lib/search.rb | 10 ++++++++++ spec/components/search_spec.rb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/search.rb b/lib/search.rb index 5dc07cb0e3e..3d6b7001660 100644 --- a/lib/search.rb +++ b/lib/search.rb @@ -118,6 +118,9 @@ class Search .order("topics_month DESC") .secured(@guardian) .limit(@limit) + if rails4? + categories = categories.references(:category_search_data) + end categories.each do |c| @results.add_result(SearchResult.from_category(c)) @@ -130,6 +133,9 @@ class Search .order("CASE WHEN username_lower = '#{@original_term.downcase}' THEN 0 ELSE 1 END") .order("last_posted_at DESC") .limit(@limit) + if rails4? + users = users.references(:user_search_data) + end users.each do |u| @results.add_result(SearchResult.from_user(u)) @@ -143,6 +149,10 @@ class Search .where("topics.visible") .where("topics.archetype <> ?", Archetype.private_message) + if rails4? + posts = posts.references(:post_search_data, {:topic => :category}) + end + # If we have a search context, prioritize those posts first if @search_context.present? diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rb index 0d5a204f1c0..06b4b8ef7c4 100644 --- a/spec/components/search_spec.rb +++ b/spec/components/search_spec.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require 'spec_helper' -require 'search' +require_dependency 'search' describe Search do