Billy Purdy


150 Experience
1 Lesson Completed
0 Questions Solved


Posted in Polymorphic, STI, or something else?

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.