Prev | Current Page 226 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

This method immediately
saves the change of these position column values to the database.
listdetails[0].insert_at(3)
This method adjusts the position column to now hold a value of 3, and, if needed,
updates other records so that no other item is at the third position.
move_lower
If the collection contains an item with a position column value that is one greater than the
current one, this method will swap the values of those position columns. This method immediately
saves the change of these position column values to the database. This example would
swap the position value for the listdetails[0] and listdetails[1] records:
listdetails[0].move_lower
CHAPTER 5 ?–  BONUS FEATURES 95
move_higher
If the collection contains an item with a position column value that is one less than the current
one, this method will swap the values of those position columns. This method immediately
saves the change of these position column values to the database. This example would swap
the position value for the listdetails[1] and listdetails[0] records:
listdetails[1].


Pages:
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238