Order in building up the SQL query fixed

This commit is contained in:
Christoph Haas 2013-08-08 21:49:46 +02:00
parent 47b3253de3
commit fca503df55

View file

@ -2,17 +2,19 @@ class PackagesController < ApplicationController
def index
@packages = Package
if params[:search]
#@packages = @packages.where("packages.name @@ :q or packages.description @@ :q", q: params[:search])
@packages = @packages.text_search(params[:search])
end
if params[:with_screenshots]=='yes'
# Limit the packages to those that have approved screenshots.
# Also eager-load the screenshots.
@packages = @packages.includes(:screenshots).where("screenshots.approved"=>true)
end
if params[:search]
@packages = @packages.where("packages.name @@ :q or packages.description @@ :q", q: params[:search])
end
@packages = @packages.order('name').limit(20)
#@packages = @packages.order('name').limit(20)
@packages = @packages.limit(20)
end
def with_screenshots