Skip to content
Snippets Groups Projects
Unverified Commit ec616e28 authored by Sébastien Gaya's avatar Sébastien Gaya Committed by GitHub
Browse files

AsLocalizedTree: use about_class.ordered instead of using arbitrary position (#2721)

* AsLocalizedTree: use about_class.ordered instead of using arbitrary position

* override program l10n ordered scope as it does not require a join
parent da5dae19
No related branches found
Tags v3.1.1
No related merge requests found
......@@ -6,7 +6,9 @@ module AsLocalizedTree
joins(:about).where(about_table_name => { parent_id: nil })
}
scope :ordered, -> (language = nil) {
joins(:about).order("#{about_table_name}.position")
# Use the ordered scope from the about class
joins(:about)
.merge(about_class.ordered(language))
}
end
......
......@@ -53,7 +53,7 @@
#
class Education::Program::Localization < ApplicationRecord
include AsLocalization
include AsLocalizedTree
include AsLocalizedTree # ordered scope is overridden below
include Contentful
include Initials
include Pathable
......@@ -92,6 +92,8 @@ class Education::Program::Localization < ApplicationRecord
validates :downloadable_summary, size: { less_than: 50.megabytes }
validates :logo, size: { less_than: 5.megabytes }
scope :ordered, -> (language = nil) { order(:slug) }
def git_path(website)
return unless published? && for_website?(website)
clean_path = Static.clean_path "#{git_path_content_prefix(website)}programs/#{path}/"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment