Ancestry gem rails 5

Ancestry gem rails 5



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





"aircraft" in this case is a string. Check your seeds file for that string.
– DickieBoy
Aug 31 at 12:47


"aircraft"





added seed file. which looks ok no? name is a string in category. My old model was named aircraft. That's why I think it's relating to that somehow even though i've destroyed model, cleared migrations etc. I feel the ancestry gem somewhere is still seeing aircraft model. I'm gonna change text in this seed file see if it still error on string. thanks.
– Bradley
Aug 31 at 13:11





Post your category model.
– DickieBoy
Aug 31 at 13:12





Ah right that's what it is picking up alright. Then this means ancestry is not doing connected to category. Category has_ancestry in model. strange. Was working before changing models.
– Bradley
Aug 31 at 13:12





I don't really know the ancestry gem that well. But seems like the parent association that gets defined by has_ancestry is expecting a Category object. Not a string. I think you simple need to remove the ' around 'aircraft'.
– DickieBoy
Aug 31 at 13:20



parent


has_ancestry


Category


'


'aircraft'






Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế