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

Passing a block of extensions to groupify generated associations #49

Open
juhazi opened this issue Jun 16, 2016 · 4 comments
Open

Passing a block of extensions to groupify generated associations #49

juhazi opened this issue Jun 16, 2016 · 4 comments

Comments

@juhazi
Copy link
Contributor

juhazi commented Jun 16, 2016

Given the models in active_record_spec I would like to:

class User < ActiveRecord::Base
  groupify :group_member do
    def some_operation_on_the_association
      proxy_association.owner.something
    end        
  end
end

to end up as if I had defined the association with the block:

class User < ActiveRecord::Base
  has_many :groups, { ... } do
    def some_operation_on_the_association
      proxy_association.owner.something
    end        
  end
end

This should not interfere with the pre-existing extend: GroupAssociationExtensions style options defined in the associations.

Does this feature seem feasible? I did not create a commit yet due to multiple directly related open branches.

@dwbutler
Copy link
Owner

It's reasonable to want more control over the auto generated associations. Similar idea as #50.

The implementation you suggested is feasible for the groups association because only one is generated. Over on the groups side, multiple member associations can be created, and each one may need to be customized differently. Maybe this can be accomplished by calling has_member multiple times, one for each member association.

@dwbutler
Copy link
Owner

@juhazi I sent you an invitation to give you collaborator access (which gives you push rights to the repo). Feel free to play around with your ideas in a branch and open a PR when you think it's ready.

@juhazi
Copy link
Contributor Author

juhazi commented Jun 27, 2016

Thank you for the access.

@juhazi
Copy link
Contributor Author

juhazi commented Jul 3, 2016

Started work in 9b87bed

If it looks ok I'll replicate it for all relations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants