Open juhazi opened 8 years ago
I would be in favor of passing in association options.
For inverse_of
specifically, in Rails 4 it is usually inferred automatically, so it doesn't need to be specified unless the names don't match up. So association options would allow that configuration to be put in place.
I started work in 3179b3e
If it looks ok I'll replicate it for all relations and merge with #49 for a PR.
@juhazi Please check out #61 - it allows you to specify custom association options using the has_group
or has_member
helpers for each association you want to create rather than using has_groups
or has_members
. Let me know if this does what you need. Thanks.
The associations generated by
groupify
andhas_members
methods lack theinverse_of
option.It should be possible to enable this on a per-call basis to keep backwards compatibility.
Example usage:
Which would generate
Alternatively allow the developer to merge in a (whitelisted?) set of extra keys to the association options hash.
Example of that:
For more info on inverse_of specifically: https://www.viget.com/articles/exploring-the-inverse-of-option-on-rails-model-associations