Skip to content

Commit

Permalink
Set explicit correspondence order
Browse files Browse the repository at this point in the history
  • Loading branch information
lmrodriguezr committed Dec 6, 2023
1 parent 77b9efe commit ecada70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/models/name.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
class Name < ApplicationRecord
has_many(:publication_names, dependent: :destroy)
has_many(:publications, through: :publication_names)
has_many(:name_correspondences, dependent: :destroy)
has_many(
:name_correspondences, -> { order(:created_at) }, dependent: :destroy
)
has_many(
:children, -> { order(:name) },
class_name: 'Name', foreign_key: 'parent_id', dependent: :nullify
Expand Down
4 changes: 3 additions & 1 deletion app/models/register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class Register < ApplicationRecord
has_one_attached(:supplementary_pdf)
has_one_attached(:certificate_pdf)
has_many(:names, -> { order('updated_at') })
has_many(:register_correspondences, dependent: :destroy)
has_many(
:register_correspondences, -> { order(:created_at) }, dependent: :destroy
)
has_many(:checks, through: :names)
has_many(:check_users, -> { distinct }, through: :checks, source: :user)
alias :correspondences :register_correspondences
Expand Down

0 comments on commit ecada70

Please sign in to comment.