Fixed sort order of packages and screenshots
Packages are sorted by most visits Screenshots are sorted by newness
This commit is contained in:
parent
e0b3721804
commit
8e668603fc
2 changed files with 5 additions and 2 deletions
|
|
@ -275,7 +275,7 @@ class PackagesController < ApplicationController
|
|||
|
||||
# Return packages matching the criteria given by parameters
|
||||
def query_packages
|
||||
packages = Package.includes(:screenshots).order(created_at: :desc)
|
||||
packages = Package.includes(:screenshots).order(visits: :desc)
|
||||
|
||||
# text search
|
||||
if params[:search].present?
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ class Package < ApplicationRecord
|
|||
# I am using "destroy_all" here so that when a package gets destroys the
|
||||
# callbacks for all dependent screenshots are executed - thus removing the
|
||||
# screenshot files from disk.
|
||||
has_many :screenshots, :inverse_of=>:package, :dependent => :destroy
|
||||
has_many :screenshots,
|
||||
-> { order(id: :desc) },
|
||||
:inverse_of=>:package,
|
||||
:dependent => :destroy
|
||||
|
||||
# default_scope {
|
||||
# order('name ASC')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue