STI and children.create
leonelgalan opened this issue · 2 comments
leonelgalan commented
When calling create on the children's type is not passed to the newly created child.
Piggybacking on the example provided
class Tag < ActiveRecord::Base
acts_as_tree
end
class WhenTag < Tag ; end
class WhereTag < Tag ; end
class WhatTag < Tag ; end
now = WhenTag.create name: 'Now'
now.children
=> []
right_now = now.children.create name: 'Right now'
right_now.type
=> nil
I was expecting the type to be kept. I don't know if I'm asking too much from closure_tree and this is just not supposed to be kept. Meanwhile I'll set it up manually or create the child using WhenTag.create and assign it to its parent later.
mceachen commented
mceachen commented
I also just updated the README. Thanks!