Skip to content

root is nil until record is persisted #254

Open
@2called-chaos

Description

@2called-chaos

I'm currently migrating from awesome_nested_set to this beautiful gem and I noticed that #root for an entry returns nil until the record got saved even if a parent is set.

My current workaround (but I don't know if it breaks anything):

has_closure_tree # MUST BE AFTER attr_accessible/self.table_name=

# fix root being nil until persisted
def root
  super || (parent && parent.root)
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions