Ask A Question

Notifications

You’re not receiving notifications from this thread.

Polymorphic, STI, or something else?

Billy Purdy asked in Databases

I am working on an app for a real estate company.

There will be 2 resources, Listings and Rentals. They will have a lot of the same data (address, beds, baths, sqft, etc.) but also different (rent vs price, MLS number for listings, year built for listings, pets allowed for rentals, etc.)

I go back and forth weather or not these should be a polymorphic relationship of a Property, or a STI with a property type, or if there is something else that is a better way.

It seems with a polymorphic association, I have to have a lot of duplicate code (controllers and views) is that true or is there a way where most everything can be written on the Property resource?

But a STI there will be a lot of empty columns for each row.

Thoughts?

Reply
Join the discussion
Create an account Log in

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

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

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