What i'm looking to do is have a base class for some of my models that has some default activerecord behavior:
class Option < ActiveRecord::Base has_many :products def some_method #stuff end #etc..etc.. end class ColorOption < Option #stuff... end class FabricOption < Option #stuff... end
However, I want ColorOption and FabricOption to each be in their own tables. I do NOT want to use STI or have a table for the base class "Option". The only way I've gotten this to work is with some non-inheritance metaprogramming magic. But I wondered if there was a way to tell AR that the base class does not need a table. Its just there for extra behavior, and to put the other subclasses in their own table as usual.
Thanks, Craig
What you want is an abstract class:
class Option < ActiveRecord::Base self.abstract_class = true end class ColorOption < Option ... end class FabricOption < Option ... end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With