class PackagesController < ApplicationController def index @packages = Package 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) end def with_screenshots end def without_screenshots end def moderate end end