According to this answer i'm trying to inplement STI and Polymorphic associations together, my code:
class Post < ActiveRecord::Base
belongs_to :content, :polymorphic => true
end
class Topic < Post #ActiveRecord::Base
has_one :post, :as => :content, :dependent => :destroy
end
class Tutorial < Post #ActiveRecord::Base
has_one :post, :as => :content, :dependent => :destroy
end
In post table i have columns content_id
, content_type
and in tables Topic, Tutorial column body
How can i create (in irb) new Tutorial or Topic ?
i tried Post.topics.new(..., :content => {body: 'my_text'})
but get an error