Skip to content

Commit

Permalink
On #101: Fixes missing sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Oct 12, 2024
1 parent 4df5ba5 commit 13e82ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/article_unit_ratio.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class ArticleUnitRatio < ApplicationRecord
belongs_to :article_version

default_scope { order(sort: :asc) }

validates :quantity, :sort, :unit, presence: true
validates :quantity, numericality: { greater_than: 0, less_than: 10**35 }
end
2 changes: 1 addition & 1 deletion app/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def articles_grouped_by_category
@articles_grouped_by_category ||= order_articles
.includes([:group_order_articles,
{ article_version: %i[article_category article_unit_ratios] }])
.order('article_versions.name')
.order('article_versions.name', 'article_unit_ratios.sort')
.group_by { |oa| oa.article_version.article_category.name }
.sort { |a, b| a[0] <=> b[0] }
end
Expand Down

0 comments on commit 13e82ca

Please sign in to comment.