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 221 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"


Using acts_as_list requires a minimal amount of work to set up. Here are the steps to follow:
1. Make sure that your Active Record associations are correctly set up.
2. Make sure that the table containing records that will essentially be the items in your
list contains an Integer column to be used for ordering the list.
3. Add the acts_as_list method to model that relates to the items your list will contain.
Let??™s break each of these steps down into a little more detail, so we fully understand them.
Step 1: Setting Up Your Associations
Technically, this isn??™t a required step at all. If you really wanted to, you could add list-like functionality
to any Active Record model simply by following the other two steps. However, it??™s most
common to deal with a list that is associated with a parent object. Every item in a top-ten list
would be related to the list title; every item on a grocery list is associated with the grocery
store you will be shopping at, and every to-do list is associated with a person or entity that is
responsible for getting the items on the list done.


Pages:
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233