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

Use Mongoid::Config.models to get the list of all available models in mongoid_slug.rake #251

Closed
wants to merge 6 commits into from

Conversation

syzspectroom
Copy link

this PR will fix #247.
My proposal is to use Mongoid::Config.models (https://www.rubydoc.info/github/mongoid/mongoid/Mongoid/Config#models-instance_method) to get the list of all available models instead of iterating through all Module constants and check if Mongoid::Slug is included in the model using const.ancestors.include?(Mongoid::Slug) which is much safer to use.
This fix will prevent the task from failing with errors like this:

TypeError: compared with non class/module

@mongoid-bot
Copy link

mongoid-bot commented Jul 11, 2018

1 Warning
⚠️ There’re library changes, but not tests. That’s OK as long as you’re refactoring existing code.

Generated by 🚫 danger

@dblock
Copy link
Collaborator

dblock commented Jul 11, 2018

Thanks, we just need a green build. I think this method didn't exist in older mongoid versions so you have to do some ifs. Changelog too pls.

It would be nice to have a test that reproduces this problem.

@kailan
Copy link
Collaborator

kailan commented Aug 17, 2018

This change is implemented in #255.

@kailan kailan closed this Aug 17, 2018
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

Successfully merging this pull request may close these issues.

TypeError: compared with non class module
4 participants