Despite the fact that I know that, at least as far as I know, this is not a standard way of creating associations with ActiveRecord. I am looking for help to implement a “hibernating" polymorphic model.
For example, consider the following basic model:
class Content < ActiveRecord::Base
self.abstract_class = true
end
And specific content:
class Audio < Content
end
Now something relatively interesting happens when using ActiveRecord, or rather Rails 3 beta 3 ActiveRecord. If you set abstract_class to false in the Content model and do the following:
Audio.create!(:path => '/dev/null')
It looks like sleep mode. That is, a content recording is created with identifier 1, and an audio recording is also created with identifier ID = 1.
# 1 , , , , , _, , , .
, # 2 , abstract_class Audio. , , Audio Audio.
, , , ActiveRecord + , Audio. , , Audio :
audio = Audio.new
[], audio.path = '/dev/null' , ActiveRecord , path , . , , ActiveRecord, .
, , , ?
, , , . ?
PS: , . , .
,
DBA