can't import the seed.rb file : HABTM issues
svenkirsten opened this issue · 4 comments
After I dumped the rails database to the seed.rb file, when I want to import the data with the command rails db:seed I get this error:
rails aborted! NameError: private constant # <Class:0x007f850e9f22a8>::HABTM_UStations referenced /Users/sven/CARGO/rails_5.1/cargo_beta/db/seeds.rb:1:in '<top (required)>' bin/rails:4:in 'require' bin/rails:4:in '<main>' Tasks: TOP => db:seed
The seed.rb file begins with these entries:
Dealer::HABTM_UStations.create!([ {ustation_id: 7, dealer_id: 2} ])
There is an issue to create the HAS_AND_BELONGS_TO_MANY records. I'm not really sure if seed_dump supports HABTM records.
I had a same issue.
rake aborted!
NameError: private constant #Class:0x00000000045c5b80::HABTM_Permissions referenced
/usr/src/app/db/seeds.rb:1:in <top (required)>' /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in
load'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in block in load' /usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in
load_dependency'
/usr/local/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in load' /usr/local/bundle/gems/railties-5.1.4/lib/rails/engine.rb:549:in
load_seed'
/usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:270:in load_seed' /usr/local/bundle/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:184:in
block (2 levels) in <top (required)>'
/usr/local/bundle/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:setup => db:seed
Same problem here.
NameError: private constant #<Class:0x0000000006787c78>::HABTM_Diags referenced
/home/maxence/Bureau/MyApp/db/seeds.rb:1:in `<top (required)>'
/home/maxence/.rvm/gems/ruby-2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:277:in `load'
/home/maxence/.rvm/gems/ruby-2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:277:in `block in load'
/home/maxence/.rvm/gems/ruby-2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
/home/maxence/.rvm/gems/ruby-2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:277:in `load'
/home/maxence/.rvm/gems/ruby-2.5.0/gems/railties-5.2.0/lib/rails/engine.rb:551:in `load_seed'
/home/maxence/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/tasks/database_tasks.rb:281:in `load_seed'
/home/maxence/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/railties/databases.rake:194:in `block (2 levels) in <top (required)>'
/home/maxence/.rvm/gems/ruby-2.5.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
/home/maxence/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:15:in `eval'
/home/maxence/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)
yeah, seed_dump does not support HAS_AND_BELONGS_TO_MANY records :(
This is also non-trivial task to fix so maybe it should be in README
I just ran into this. I guess I just have to do a db dump / restore huh?