How to handle listing multiple model types?

Posted 3 months ago by RoboRobok

I have some documents in database. They come in different types, so I have several models representing documents. Now, what if I need to list them all by column, let's say user_id?

My initial database design had each type of the document reside in its own table, like invoices, proofs etc. I also had separate documents table with user_id, document_id and type, using polymorphic relations.

This is a little troublesome though, because I need to use user_id very often for each document type and fetching it through morphing each time is a little much.

How would you guys define this relation?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.