0

I have 3-4 different types of clients for a photo site. Musician, wedding, portrait, and general with the possibility of adding more types. The idea is each type will have a shared set of attributes such as name email etc. but each will have their own too.

Musicians will have band name, members, genre, while wedding will have venue, coordinator details and so on.

I think this is the right way to go about it, correct me if there's an easier way to track multiple shared and unique attributes.

I was reading up on single table inheritance and one place said to use it only if the models have the same attributes but different behavior. How can I structure my models to meet this? From a more generic OOP standpoint this makes a lot of sense to me, but I'm having doubt's from that clause of STI.

Phix
  • 9,364
  • 4
  • 35
  • 62

1 Answers1

2

Your use case sounds like a good one for STI. The key thing is that the children share some attributes with their siblings, not all attributes. I found this overview helpful:

http://samurails.com/tutorial/single-table-inheritance-with-rails-4-part-1/

Dan Kohn
  • 33,811
  • 9
  • 84
  • 100
  • Funnily enough that's the article I read that mentioned same attrs different behavior! Glad I'm on the right track, thanks! – Phix Aug 24 '14 at 20:11
  • Domain changed, the mentioned article is now available there: http://samurails.com/tutorial/single-table-inheritance-with-rails-4-part-1/ – T_Dnzt Jun 25 '15 at 16:15