Fixed eager loading of packages/screenshots
This commit is contained in:
parent
93177ab578
commit
a5b31a2dcc
3 changed files with 4 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
class PackagesController < ApplicationController
|
class PackagesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@packages = Package
|
@packages = Package.includes(:screenshots)
|
||||||
|
|
||||||
if params[:search]
|
if params[:search]
|
||||||
@packages = @packages.text_search(params[:search])
|
@packages = @packages.text_search(params[:search])
|
||||||
|
|
@ -9,10 +9,9 @@ class PackagesController < ApplicationController
|
||||||
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.where("screenshots.approved"=>true)
|
||||||
end
|
end
|
||||||
|
|
||||||
#@packages = @packages.limit(20)
|
|
||||||
@packages = @packages.page(params[:page]).per(12)
|
@packages = @packages.page(params[:page]).per(12)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
class Screenshot < ActiveRecord::Base
|
class Screenshot < ActiveRecord::Base
|
||||||
belongs_to :package, :inverse_of=>:screenshots
|
belongs_to :package, :inverse_of=>:screenshots
|
||||||
|
|
||||||
default_scope {
|
default_scope {
|
||||||
order('uploaddatetime DESC')
|
order('uploaddatetime DESC')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue