From 7caf5ba666046fd57e6a2fb91b5a978a88c1ba86 Mon Sep 17 00:00:00 2001 From: Sascha Karnatz Date: Thu, 7 Nov 2024 15:34:41 +0100 Subject: [PATCH] Use public_on instead of published_at for pg_search_documents The public_on date will only be set the first time a page was published. Published_at instead will be set each time a page is published. It makes more sense to prefer public_on. --- app/extensions/alchemy/pg_search/page_extension.rb | 2 +- spec/models/page_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/extensions/alchemy/pg_search/page_extension.rb b/app/extensions/alchemy/pg_search/page_extension.rb index 23ccdc3..18c5a03 100644 --- a/app/extensions/alchemy/pg_search/page_extension.rb +++ b/app/extensions/alchemy/pg_search/page_extension.rb @@ -10,7 +10,7 @@ def self.prepended(base) :meta_keywords, :name, ], - additional_attributes: ->(page) { { page_id: page.id, searchable_created_at: page.published_at } }, + additional_attributes: ->(page) { { page_id: page.id, searchable_created_at: page.public_on } }, if: :searchable?, ) end diff --git a/spec/models/page_spec.rb b/spec/models/page_spec.rb index 0dc41ab..5f3e814 100644 --- a/spec/models/page_spec.rb +++ b/spec/models/page_spec.rb @@ -76,7 +76,7 @@ end it "stores searchable created_at" do - expect(page.pg_search_document.searchable_created_at).to eq(page.published_at) + expect(page.pg_search_document.searchable_created_at).to eq(page.public_on) end end end