diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-08-01 14:46:04 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-08-01 14:46:04 +0200 |
| commit | 1384756b81c719f899359efc9125e80fae8614c0 (patch) | |
| tree | c8141fedeb7a03f646111177585ac05321e5f981 /app/models/page.rb | |
| parent | 52e260a4d7e3ac93c203bda716c37207d5f6cbbb (diff) | |
Allow aggregate to order by slug and paint chapters list more nicely
Diffstat (limited to 'app/models/page.rb')
| -rw-r--r-- | app/models/page.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/page.rb b/app/models/page.rb index a66527da..8313b1d4 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -92,6 +92,11 @@ class Page < ApplicationRecord | |||
| 92 | .paginate(:page => page, :per_page => options[:limit]) | 92 | .paginate(:page => page, :per_page => options[:limit]) |
| 93 | end | 93 | end |
| 94 | 94 | ||
| 95 | if options[:order_by] == "slug" | ||
| 96 | return scope.order(Arel.sql("MIN(LOWER(nodes.slug)) #{direction}")) | ||
| 97 | .paginate(:page => page, :per_page => options[:limit]) | ||
| 98 | end | ||
| 99 | |||
| 95 | column = options[:order_by].to_s.sub(/\Apages\./, "") | 100 | column = options[:order_by].to_s.sub(/\Apages\./, "") |
| 96 | column = "id" unless %w[id published_at created_at updated_at].include?(column) | 101 | column = "id" unless %w[id published_at created_at updated_at].include?(column) |
| 97 | 102 | ||
