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

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

So in most cases, you??™ll deal with acts_as_
list along with models that have data associations, and when that is the case, the acts_as_list
method will generally go in the model that has the belongs_to method, as you can see here:
class TopTenTopics < ActiveRecord::Base
has_many :top_ten_items
end
class TopTenItems < ActiveRecord::Base
belongs_to :top_ten_topics
acts_as_list :scope => :top_ten_topic
end
Because we cover data associations in detail in Chapter 4, we will not dive into the design
issues of the TopTen associations at this time. Just know that a given top-ten topic record would
have a number of associated top-ten item records for this example.
CHAPTER 5 ?–  BONUS FEATURES 93
Step 2: Defining an Integer Column Used for Sorting the List
Sometimes, like with a grocery list, you won??™t really care about the order of the list, but that
doesn??™t mean that it doesn??™t have an order. The list has a beginning and an end, and each item
is either before or after other items on the list. In fact, order is a basic and fundamental element
of all lists, so it should come as no surprise that, to use acts_as_list, within Active Record you
need to have an integer field within your database that stores the order of items within your list.


Pages:
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6