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

Add the has_member and has_group association helpers to specify model class name #60

Conversation

joelvh
Copy link
Collaborator

@joelvh joelvh commented May 9, 2017

We wanted to create a users association with a CustomUser class. We added the option to use has_member :users, class_name: 'CustomUser', so you can specify the class for specific associations. This is backwards compatible with just passing in association names to has_members.

I think that the only change that's missing from Mongoid is default_members: true option for has_member

@joelvh joelvh changed the title Add the ability to specify a map of association names to class names Add the ability to specify a has_members map of association names to class names May 9, 2017
@dwbutler
Copy link
Owner

dwbutler commented May 9, 2017

I understand the need to customize the associations generated by Groupify.

In this case, I think it will ultimately be simpler and more useful to have a separate has_member method which takes an association name and a hash of association options.

has_member :users, class_name: 'CustomUserClass'
has_member :admins, class_name: 'CustomAdminClass'

@joelvh
Copy link
Collaborator Author

joelvh commented May 9, 2017

@dwbutler OK, I will refactor with has_member method and take a look at the tests that are failing.

@joelvh joelvh changed the title Add the ability to specify a has_members map of association names to class names Add the ability to specify a has_member association with custom class name May 9, 2017
@joelvh
Copy link
Collaborator Author

joelvh commented May 9, 2017

@dwbutler updated with has_member method. I also noticed that there was a missing association_name argument to the associate_member_class method in Mongoid, which is now added....

@joelvh joelvh changed the title Add the ability to specify a has_member association with custom class name Add the has_member and has_group association helpers to specify model class name May 10, 2017
@dwbutler
Copy link
Owner

Related: #47

@joelvh
Copy link
Collaborator Author

joelvh commented Aug 4, 2017

@dwbutler closing this in favor of #61, which incorporates this addition.

@joelvh joelvh closed this Aug 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants