Ask A Question

Notifications

You’re not receiving notifications from this thread.

Best practices for self-referential habtm setup?

John Athayde asked in Rails
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?
Reply
Anyone have any thoughts on this?
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.