views:

24

answers:

1

If I have a collection of objects through a 'has and belongs to many' association in Rails (e.g. the album 'summer photos' has a collection of photos), how can I arbitrarily change the order of the elements in that collection? For example, there is a default index that would yield @album.images[0] or .first. how would I go about changing the collection, so that a another given image in that collection has the first spot? I think I can remove all the previous items from the collection, and then add them all back on, but that seems cumbersome, and not sure it really works even.

A: 

acts_as_list is the standard way to do this.

Jordan