
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
An alternative to nested_sets and acts_as_tree. Designed to be a drop in replacement for acts_as_tree. Replaces betternestedset without the slow inserts when dealing with a large dataset. Used by upillar.com on a dataset of over 900,000 categories with no slow downs. In tests it shows a 285% speed increase on inserts with a dataset of 100k categories. As datasets become larger its insert speed stays about the same when nested_sets become slower. In all of my tests read speeds have been comparable with nested sets on everything but all_children which is inperceptibly slower on a dataset of 100k than betternestedset.
Add this line to your application's Gemfile:
gem 'acts_as_better_tree'
And then execute:
$ bundle
Or install it yourself as:
$ gem install acts_as_better_tree
Required fields are parent_id, root_id, csv_ids.
create_table :categories do |t|
t.column :root_id, :integer
t.column :parent_id, :integer
t.column :csv_ids, :string
t.column :name, :string
end
If upgrading from acts_as_tree just add root_id and csv_ids and run Category.tree_to_better_tree!
class Category < ActiveRecord::Base
acts_as_better_tree :order => "name"
end
Example:
root
\_ child1
\_ subchild1
\_ subchild2
root = Category.create("name" => "root")
child1 = root.children.create("name" => "child1")
subchild1 = child1.children.create("name" => "subchild1")
root.parent # => nil
child1.parent # => root
root.children # => [child1]
root.children.first.children.first # => subchild1
child1.self_and_ancestors # => [root, child1]
child1.ancestors
child1.siblings
child1.self_and_siblings
child1.move_to_child_of(parent)
child1.childless?
child1.ancestor_of?(subchild1)
child1.descendant_of?(root)
root.to_csv # => "root,child1,subchild1\n" returns and array of all children
Category.to_csv # => "root,child1,subchild1\nroot,child1,subchild2\n" returns entire tree in a csv string
Copyright (c) 2008 Isaac Sloan, released under the MIT license. Inspired by David Heinemeier Hansson's acts_as_tree
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that acts_as_better_tree demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.