Better use of Rails' tag helpers. Added list view.

This commit is contained in:
Christoph Haas 2013-08-25 23:38:50 +02:00
parent 869b87bc7b
commit e3e1871a8f
4 changed files with 63 additions and 24 deletions

View file

@ -3,16 +3,22 @@ class PackagesController < ApplicationController
@packages = Package.includes(:screenshots)
if params[:search]
@packages = @packages.text_search(params[:search])
@packages = @packages.text_search(params[:search][:query])
end
if params[:with_screenshots]=='yes'
# Limit the packages to those that have approved screenshots.
# Also eager-load the screenshots.
@packages = @packages.where("screenshots.approved"=>true)
end
#if params[:with_screenshots]=='yes'
# # Limit the packages to those that have approved screenshots.
# # Also eager-load the screenshots.
# @packages = @packages.where("screenshots.approved"=>true)
#end
@packages = @packages.page(params[:page]).per(12)
if params[:search][:display]=='list'
@view='list'
else
@view='grid'
end
end
def with_screenshots