I have the following scenario
class XYZ < ActiveRecord::Base
has_many :abcs
end
class ABC < ActiveRecord::Base
belongs_to :xyz
end
class A < ABC
end
class B < ABC
end
class C < ABC
end
The model ABC doesn't have any controller, or view. Data related to ABC will be inserted from the XYZ views and controllers. The user sets a type value for ABC which might be either A, B or C.
And as per the type the corresponding STI subclass must be instantiated and the data must be saved appropriately. But here the subclasses are not getting instantiated, the data is getting saved perfectly. But I am doing it the wrong way as I have written the code of the subclasses into the parent STI class because that code was not getting called in the subclass.
Please give suggesstions and provide some solutions or tutorials.
Thanx in advance.