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
|
||||
@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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue