class PackagesController < ApplicationController def index @packages = Package.includes(:screenshots) if params[:query] @packages = @packages.text_search(params[:query]) end # Limit the packages to those that have approved screenshots. # Also eager-load the screenshots. if params[:show]=='onlywith' @packages = @packages.where("screenshots.approved"=>true) end @packages = @packages.page(params[:page]).per(12) end def with_screenshots end def without_screenshots end def moderate end end