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

Should handle polymorphic associations #5

Open
ronen opened this issue Oct 31, 2011 · 3 comments
Open

Should handle polymorphic associations #5

ronen opened this issue Oct 31, 2011 · 3 comments

Comments

@ronen
Copy link
Member

ronen commented Oct 31, 2011

Recognize a polymorphic association by the convention of columns named 'foo_id' and 'foo_type', when those columns have the appropriate types and table 'foos' exists.

This would build on Issue #4 -- creating associations without foreign key constraints

@romdim
Copy link

romdim commented Apr 23, 2016

Hello there!
Seems like a great gem overall and I just started using it, the thing is that I already have a lot of polymorphic associations.
Is there a chance for this feature to come in life?
Thank you for all your effort!

@ronen
Copy link
Member Author

ronen commented Apr 25, 2016

Hello, I'd be happy to accept a PR but unlikely to have time to work on it myself.

Handling the polymorphic belongs_to association should be reasonably straightforward. But a tricky question would be how to automatically generate the reverse has_many associations (since they depend on the contents of the _type column); I have some half-baked ideas but not sure if they'd really work. If there's anyone out there (you?) who wants to try it I'm happy to discuss.

@romdim
Copy link

romdim commented Apr 25, 2016

Unfortunately I'm not in a better position myself and additionally not enough experience with ruby to work on it I think.. When I find any time I'd be happy to discuss it with you! Will use the basic way for now.. Cheers!

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

No branches or pull requests

2 participants