Skip to main content

Best practices for self-referential habtm setup?

Rails • Asked by John Athayde
Basic concept:
Patch collecting app. There are issuing entities in the system that issue patches. That model is "issues". In many cases, these are difficult to tell apart. So I want to add a similar issues functionality that would be self referential on the issues table. 

When creating this, it should go both ways. If patch 1 looks like patch 5, then patch 5 looks like patch 1. Do I need to do double entry or would two indexes (issue_id, similar_issue_id) work? 

This can often be many different issues, so would this make more sense to have issue_id and then have similar_issues_ids as a JSON or other multiple value store?

Anyone have any thoughts on this?

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.