SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 242 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

find(1)
CHAPTER 5 ?–  BONUS FEATURES 103
With all this preliminary stuff out of the way, we should be ready to explore the nested
set??™s methods.
root?
Since nested set structures are fairly complex, you??™ll often find yourself wanting to do a quick
check just to see where in the structure you are. The root? method simply returns true if the
current record is the root of the structure. The following example will print true if the temp
record is the root of the tree:
puts temp.root? #=> true
child?
The child? method returns true if the current record is a child within the current structure.
This will print true if the record is not the root of the tree and false if it is:
puts temp.child? #=> false
unknown?
Depending on the depth of your structures, it can become pretty easy to lose track of the depth
of the current item. The unknown? method returns true if it can not currently be determined if
the current record is the root or a child.
puts temp.unknown? #=> false
add_child
Use add_child to add a child node to the current object in the tree.


Pages:
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6