| Module | SymetrieCom::Acts::NestedSet::ClassMethods::SingletonMethods |
| In: |
lib/symetrie_com/acts_as_better_nested_set.rb
|
Checks the left/right indexes of all records, returning the number of records checked. Throws ActiveRecord::ActiveRecordError if it finds a problem.
Most query methods are wrapped in with_scope to provide further filtering find_in_nested_set(what, outer_scope, inner_scope) inner scope is user supplied, while outer_scope is the normal query this way the user can override most scope attributes, except :conditions which is merged; use :reverse => true to sort result in reverse direction
Loop through set using block pass :nested => false when result is not fully parent-child relational for example with filtered result sets Set options[:sort_on] to the name of a column you want to sort on (optional).
Re-calculate the left/right values of all nodes. Can be used to convert ordinary trees into nested sets.
Loop and create a nested array of hashes (with children property) pass :nested => false when result is not fully parent-child relational for example with filtered result sets
Loop and create a nested xml representation of nodes with attributes pass :nested => false when result is not fully parent-child relational for example with filtered result sets
Loop and create an xml structure. The following options are available :root sets the root tag, :children sets the siblings tag :record sets the node item tag, if given see also: result_to_array and ActiveRecord::XmlSerialization
Returns an SQL fragment that matches items and all of their descendants, for use in a WHERE clause. You can pass it a single object, a single ID, or an array of objects and/or IDs.
# if a.lft = 2, a.rgt = 7, b.lft = 12 and b.rgt = 13 Set.sql_for([a,b]) # returns "((lft BETWEEN 2 AND 7) OR (lft BETWEEN 12 AND 13))"
Returns "1 != 1" if passed no items. If you need to exclude items, just use "NOT (#{sql_for(items)})". Note that if you have multiple trees, it is up to you to apply your scope condition.