Displaying 2 results from an estimated 2 matches for "non_fiction".
2005 Oct 12
2
Help with act_as_nested_set
...end
Category.delete_all
def add_child(parent, name)
child = Category.create(:name => name)
parent.add_child(child) || fail("Couldn''t add #{name}")
child
end
root = Category.create(:name => "Books")
fiction = add_child(root, "Fiction")
non_fiction = add_child(root, "Non Fiction")
add_child(non_fiction, "Science")
add_child(non_fiction, "History")
computers = add_child(non_fiction, "Computers")
add_child(computers, "Software")
add_chi...
2006 Jul 20
3
acts_as_tree
...create categories and subcategories using the following code explained in
(Agile Web Development With Rails) book:
----------------------------------------------------------------
root = Category.create(:name => "Books")
fiction = root.children.create(:name => "Fiction")
non_fiction = root.children.create(:name => "Non Fiction")
non_fiction.children.create(:name => "Computers")
non_fiction.children.create(:name => "Science")
non_fiction.children.create(:name => "Art History")
fiction.children.create(:name => "Mystery&...