0

i have an asset class which have type, name, label etc.

Asset types are: avatar, image, video, summary etc.

I want to have Video < Asset type only for type = 'video', but for all other types - Asset should be used.

If i use self.inheritance_column = 'type' - it fails, because cant find Avatar class. Is there any approach how to map all types to Asset class except video?

Thanks, Kirill Salykin

Kirill Salykin
  • 681
  • 6
  • 19

1 Answers1

1

That won't work. You're either doing STI with those types or you aren't.

The way to do it is use type as your STI column, and something like asset_type as your categorization column. Then only video gets the type column, all other assets use the asset_type column to tell what's what.

Andrew
  • 42,517
  • 51
  • 181
  • 281
  • I see, maybe there any way to monkey patch class name resolving routin or some callback exists? – Kirill Salykin Nov 12 '12 at 15:51
  • You're going to create far more headaches than are worth it. If you want two different behaviors just use two different column names :) – Andrew Nov 12 '12 at 15:59