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
|
||||
def index
|
||||
@packages = Package
|
||||
@packages = Package.includes(:screenshots)
|
||||
|
||||
if params[:search]
|
||||
@packages = @packages.text_search(params[:search])
|
||||
|
|
@ -9,10 +9,9 @@ class PackagesController < ApplicationController
|
|||
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)
|
||||
@packages = @packages.where("screenshots.approved"=>true)
|
||||
end
|
||||
|
||||
#@packages = @packages.limit(20)
|
||||
@packages = @packages.page(params[:page]).per(12)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
class Screenshot < ActiveRecord::Base
|
||||
belongs_to :package, :inverse_of=>:screenshots
|
||||
|
||||
default_scope {
|
||||
order('uploaddatetime DESC')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,4 +36,4 @@
|
|||
</ul>
|
||||
<% end %>
|
||||
|
||||
<!--<button class="btn btn-large btn-block" type="button">More screenshots…</button>-->
|
||||
<!--<button class="btn btn-large btn-block" type="button">More screenshots…</button>-->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue