Skip to content

Either enable custom association options or set inverse_of for the relations #50

@juhazi

Description

@juhazi

The associations generated by groupify and has_members methods lack the inverse_of option.

It should be possible to enable this on a per-call basis to keep backwards compatibility.

Example usage:

class Organization < Group
  has_members :managers,
    inverse_of: true
end

Which would generate

class Organization < ActiveRecord::Base
  has_many :managers,
    through: :group_memberships_as_group,
    inverse_of: :organizations,
    ... # The rest of the options 
end

Alternatively allow the developer to merge in a (whitelisted?) set of extra keys to the association options hash.

Example of that:

class Organization < Group
  has_members :managers,
    inverse_of: :organizations
end

For more info on inverse_of specifically: https://www.viget.com/articles/exploring-the-inverse-of-option-on-rails-model-associations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions