By default, acts_as_list assumes that this field name is position, but you can override that by
passing the name of the column with your acts_as_list method, as the following example
shows (we use the column named listorder instead of the default column name of position):
class TopTenItems < ActiveRecord::Base
belongs_to :top_ten_topics
acts_as_list :scope => :top_ten_topic, :column => "list_order"
end
Requiring this integer field becomes obvious when you think about how you would actually
implement some of the list-like features if you had to write the code yourself. For example,
if you want to move an item lower in the list, you would obviously need to know the current
position and have some way of adjusting that position as well as the position of all the items
on the list that were previously below the item you are moving.
?– Note Many of the acts_as_list methods attempt to directly manipulate the value of integer field sort
key within the database even if you never make a call to the update or save method.
Step 3: Adding the acts_as_list Method
Adding the acts_as_list method is what really includes all the list-like functionality to your
model.
Pages:
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235