Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't import the seed.rb file : HABTM issues #130

Open
svenkirsten opened this issue Oct 17, 2017 · 4 comments
Open

can't import the seed.rb file : HABTM issues #130

svenkirsten opened this issue Oct 17, 2017 · 4 comments

Comments

@svenkirsten
Copy link

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.

@shaoyangyu
Copy link

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

@maxence33
Copy link

maxence33 commented Aug 14, 2018

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)

@confiq
Copy link

confiq commented Nov 16, 2018

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

@Tectract
Copy link

I just ran into this. I guess I just have to do a db dump / restore huh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants