Skip to main content

Polymorphic, STI, or something else?

Databases • Asked by Billy Purdy

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?


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.