-
Notifications
You must be signed in to change notification settings - Fork 20
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
Mongoidalize throws NameError, uninitialized constant Mongoid::Relations #55
Comments
Mistakenly closed the issue, no worries. |
Hi @Eidar, I'm wondering if there isn't a mismatch between the versions of mongoid_alize and mongoid. Can you create a fresh repo with just the Gemfile, your models, and enough code to reproduce the error you're seeing? |
Yes, same problem still. Ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32] |
Are you able to share that fresh repo with me? I want to help but have very limited time this week. One suggestion would be to try with Mongoid up to 6.4. The last contribution (from @joe1chen) stated that as the most recent supported version. |
Here you go: https://github.com/Eidar/mongoid_alize_test You can take it easy, I solved it in some other way but I'm still interested in a solution here. As you say, you have very limited time and I'm not in that much of a hurry :D |
I also saw the issue with Mongoid 7 and did not have the time to look into the issue with Mongoid 7. Since we are not using Mongoid 7, there was not a big reason for us to investigate this any further. But yes we should figure out the issue with Mongoid 7 eventually. |
No need for a test repository. Just updating the gems to Mongoid 7 and running the existing specs is enough to reproduce the issue. |
Ok, it looks like this issue with Mongoid 7 was also raised in the mongoid-rspec library and subsequently fixed (see https://github.com/mongoid/mongoid-rspec/pull/212/files). Looks like Mongoid::Relations needs to be replaced with Mongoid:Associations in version 7 and up. The pull request from the mongoid-rspec has all the details. If someone has some time to replicate this work, please do so. |
Thanks @joe1chen for looking at that! |
project isn't complicated, but finding my way around mongoid relationships has been. It would be nice to find some in depth explanation.
I couldn't make my code work however I set them up so I managed to find Mongoid_Alize: https://github.com/dzello/mongoid_alize
Yet when I do it with alize or alize_to/_from, console gives me back an error on Mongoid::Relations in Ruby2.3.3/lib/ruby/gems/2.3.0/bundler/gems/mongoid_alize-b9175f4e3165/lib/mongoid/alize/macros.rb:79:in `_alize_relation_types'"
I have also included eager loading with identity_map_enabled: true in mongoid.yml
So here's the code:
Currency.rb
Value.rb
ApiService.rb
Expected result: save all 13 iterations in MongoDB with their relations.
It would be much obliged to hear some explanation here cause I'm uninspired and stuck in place. I have some background in programming and I have a feeling that it shouldn't be that complicated.
I can save either Currency model or Value but not both with their relations. Other idea is to do it manually by adding a custom foreign_id and making a method in the model which will populate hash. But that could lead to future performance issues.
Any help is appreciated, thank you :)
The text was updated successfully, but these errors were encountered: