an attempt at getting this working on rails 4 ... not fruitful

This commit is contained in:
Sam 2013-08-02 10:31:36 +10:00
parent 09f9ed3609
commit 3246f066c6
2 changed files with 11 additions and 1 deletions

View File

@ -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?

View File

@ -1,7 +1,7 @@
# encoding: utf-8
require 'spec_helper'
require 'search'
require_dependency 'search'
describe Search do