diff --git a/db/migrate/20160803094931_wiki_menu_titles_to_slug.rb b/db/migrate/20160803094931_wiki_menu_titles_to_slug.rb index 4b73987ce0..d55c291de5 100644 --- a/db/migrate/20160803094931_wiki_menu_titles_to_slug.rb +++ b/db/migrate/20160803094931_wiki_menu_titles_to_slug.rb @@ -14,8 +14,13 @@ class WikiMenuTitlesToSlug < ActiveRecord::Migration def migrate_menu_items ActiveRecord::Base.transaction do ::MenuItems::WikiMenuItem.includes(:wiki).find_each do |item| + + # We need the associated wiki to be present + wiki = item.wiki + next if wiki.nil? + # Find the page - wiki_page = item.wiki.find_page(item.title) + wiki_page = wiki.find_page(item.title) # Set the title to the actual slug # If the page could not be found, migrate the title to form a slug