Search feature repaired

This commit is contained in:
Christoph Haas 2014-11-30 23:20:26 +01:00
parent f940e96014
commit f3a8b7c3a5
8 changed files with 60 additions and 29 deletions

View file

@ -1,11 +1,16 @@
class Package < ActiveRecord::Base
# PostgreSQL-based full-text search:
# https://github.com/Casecommons/pg_search
include PgSearch
# TODO: Make search weighted on users' rating
pg_search_scope :general_search, :against => [:name, :description, :long_description]
has_many :screenshots, :inverse_of=>:package
default_scope {
order('name ASC')
}
# Return a query of all packages that have screenshots
def self.with_screenshots
# Query for all packages who's ID appears in a screenshot's "package_id" field