
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
acts-as-tree-with-dotted-ids
Advanced tools
= acts_as_tree_with_dotted_ids
This is an extension to Rails good old acts_as_tree which uses an extra "dotted_ids" column which stores the path of the node as a string of record IDs joined by dots, hence the name.
This optimization solves performance issues related to in-database tree structure by allowing for direct O(1) ancestor/child verification and O(N) subtree access with one single query.
class Category < ActiveRecord::Base acts_as_tree_with_dotted_ids :order => "name" end
Example:
root _ child1 _ subchild1 _ subchild2
Usage:
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.ancestors_of?(subchild2) # => true subchild1.descendant_of?(root) # => true
root.id # 1 child1.id # 2 subchild1.id # 3 root.dotted_ids # "1" child1.dotted_ids # "1.2" subchild1.dotted_ids # "1.2.3"
== Improvements
The plugin adds the following instance methods:
The following methods of have been rewritten to take advantage of the dotted IDs:
== Migration
If you already have an +acts_as_tree+ model, you can easily upgrade it to take advantage of the dotted IDs.
== Compatibility
From version 1.2.0, this gem is only compatible with Rails 4.x and up.
== Thanks
Kudos to all the contributors to the original plugin.
Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license
Copyright (c) 2008 Xavier Defrang, released under the MIT license
FAQs
Unknown package
We found that acts-as-tree-with-dotted-ids demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.