From 6d76665fde7487ef2effcad75bc318ba81dfb909 Mon Sep 17 00:00:00 2001 From: "Luis M. Rodriguez-R" Date: Tue, 26 Nov 2024 11:05:06 +0300 Subject: [PATCH] PgSQL issue fixed --- app/controllers/registers_controller.rb | 2 +- app/models/register.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/registers_controller.rb b/app/controllers/registers_controller.rb index 06beed5..177f967 100644 --- a/app/controllers/registers_controller.rb +++ b/app/controllers/registers_controller.rb @@ -85,7 +85,7 @@ def index(status = :validated) # GET /registers/r:abcd.json def show @register.update_name_order if @register.names.first.name_order.nil? - @names = @register.names + @names = @register.names.order(:name_order, created_at: :desc) @count = @names.count @names &&= @names.where(rank: params[:rank]) if params[:rank].present? @names &&= @names.paginate(page: params[:page], per_page: 30) diff --git a/app/models/register.rb b/app/models/register.rb index 77c0d54..6f140e3 100644 --- a/app/models/register.rb +++ b/app/models/register.rb @@ -12,7 +12,8 @@ class Register < ApplicationRecord has_one_attached(:publication_pdf) has_one_attached(:supplementary_pdf) has_one_attached(:certificate_pdf) - has_many(:names, -> { order(:name_order, created_at: :desc) }) + #has_many(:names, -> { order(:name_order, created_at: :desc) }) + has_many(:names) has_many( :register_correspondences, -> { order(:created_at) }, dependent: :destroy )