Reputation: 932
So I added the ancestry gem to my rails app. I was using model named aircraft and this had a relationship with my category model. All worked fine when running a seed to create to categories and subcategories in my app.
I then decided to delete my aircraft model name and add a listing model. I done the following steps to delete the aircraft model.
reverted back to the migration. rails db:migrate:down VERSION=20180830175747
removed the file then ran the rails destroy model Aircraft
and then had some issues with below error. So I reverted back to my first migration, deleted category model, listing model etc. Removed ancestry gem.
Then started a fresh. All looked good until I try run a seed file then I get the following error.
rake aborted!
NoMethodError: undefined method `child_ancestry' for "aircraft":String
/Users/bradley/Development/current/global_abx/db/seeds.rb:10:in `<main>'
Anybody have any clue as to why the child_ancestry still refers to anything related to aircraft??
Thanks a million.
Seed file:
aircraft = Category.create(name: 'Aircraft')
aircraft_jets = Category.create(name: 'Jets', parent: 'aircraft')
aircraft_helicopter = Category.create(name: 'Helicopter', parent: 'aircraft')
aircraft_light = Category.create(name: 'Light', parent: 'aircraft')
aircraft_twin_piston = Category.create(name: 'Twin Piston', parent: 'aircraft')
Category.rb
class Category < ApplicationRecord
has_ancestry
end
Upvotes: 0
Views: 339