Prev | Current Page 227 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

move_lower
move_to_bottom
The move_to_bottom method changes the value of the position column to the highest-numbered
position column value in the collection (thinking of position as an index) and adjusts the
other positions accordingly. This method immediately saves the change of these position
column values to the database. This example moves the first record to the end of the list:
listdetails[0].move_to_bottom
move_to_top
This method changes the value of the position column to 1 and adjusts the other positions
accordingly. This method immediately saves the change of these position column values to
the database. This example moves the fourth item in the list to the top of the list:
listdetails[3].move_to_top
remove_from_list
This method removes the specified item from the list in memory and updates the other items??™
position columns to reflect the absence of this item from the list. This method immediately
saves the change of these position column values to the database. This example removes the
first record from the in-memory collection and subtracts one from each of the ???lower??? items??™
position column values:
listdetails[0].


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