diff --git a/app/models/spina/navigation.rb b/app/models/spina/navigation.rb index e8181f411..2c2f4140e 100644 --- a/app/models/spina/navigation.rb +++ b/app/models/spina/navigation.rb @@ -7,5 +7,9 @@ class Navigation < ApplicationRecord validates :name, :label, presence: true validates :name, uniqueness: true + + def cache_key + super + "_" + Globalize.locale.to_s + end end end \ No newline at end of file diff --git a/app/models/spina/navigation_item.rb b/app/models/spina/navigation_item.rb index 5294990a0..a0b44d2e1 100644 --- a/app/models/spina/navigation_item.rb +++ b/app/models/spina/navigation_item.rb @@ -1,6 +1,6 @@ module Spina class NavigationItem < ApplicationRecord - belongs_to :navigation + belongs_to :navigation, touch: true belongs_to :page has_ancestry orphan_strategy: :adopt diff --git a/app/models/spina/page.rb b/app/models/spina/page.rb index 474a63548..03cdcb7b6 100644 --- a/app/models/spina/page.rb +++ b/app/models/spina/page.rb @@ -24,6 +24,7 @@ class Page < ApplicationRecord # Save children to update all materialized_paths after_save :save_children + after_save :touch_navigations # Create a 301 redirect if materialized_path changed after_save :rewrite_rule @@ -92,6 +93,10 @@ def view_template_page_parts(theme) private + def touch_navigations + navigations.update_all(updated_at: Time.zone.now) + end + def rewrite_rule RewriteRule.create(old_path: old_path, new_path: materialized_path) if old_path != materialized_path end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 523f898a7..929cae087 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170803183152) do +ActiveRecord::Schema.define(version: 8) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql"