Module: SimpleContentManagement::Breadcrumbs

Included in:
SimpleMenusController, SimplePage
Defined in:
lib/simple_content_management/breadcrumbs.rb

Instance Method Summary collapse

Instance Method Details

#reconstruct_breadcrumbsObject



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/simple_content_management/breadcrumbs.rb', line 2

def reconstruct_breadcrumbs
  pages = SimpleContentManagement::SimplePage.active.all
  menu_items = SimpleContentManagement::SimpleMenuItem.all
  menu_item_ids = menu_items.map(&:id)

  pages.each do |page|
    next if menu_item_ids.include?(page.preferred_menu_item_id) || page.simple_menu_items.first.nil?
    page.preferred_menu_item_id = page.simple_menu_items.first.id
    page.save
  end
end