Order in building up the SQL query fixed
This commit is contained in:
parent
47b3253de3
commit
fca503df55
1 changed files with 7 additions and 5 deletions
|
|
@ -2,17 +2,19 @@ class PackagesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@packages = Package
|
@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'
|
if params[:with_screenshots]=='yes'
|
||||||
# Limit the packages to those that have approved screenshots.
|
# Limit the packages to those that have approved screenshots.
|
||||||
# Also eager-load the screenshots.
|
# Also eager-load the screenshots.
|
||||||
@packages = @packages.includes(:screenshots).where("screenshots.approved"=>true)
|
@packages = @packages.includes(:screenshots).where("screenshots.approved"=>true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:search]
|
#@packages = @packages.order('name').limit(20)
|
||||||
@packages = @packages.where("packages.name @@ :q or packages.description @@ :q", q: params[:search])
|
@packages = @packages.limit(20)
|
||||||
end
|
|
||||||
|
|
||||||
@packages = @packages.order('name').limit(20)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_screenshots
|
def with_screenshots
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue