Class: Postnhost::Navigation

Inherits:
ApplicationRecord show all
Defined in:
app/models/postnhost/navigation.rb

Instance Method Summary collapse

Instance Method Details

#replace_tree!(tree:, locale_key:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/postnhost/navigation.rb', line 14

def replace_tree!(tree:, locale_key:)
  locale = locale_key.to_s

  transaction do
    old_items = navigation_items.index_by(&:id)
    navigation_items.delete_all
    create_container_items!("header", tree.fetch("header", []), locale, old_items)
    create_container_items!("footer", tree.fetch("footer", []), locale, old_items)
    setting.touch
  end
end