One thing I took away from your courses was to try and stick to the seven standard actions and I’ve found this very helpful in focusing my thinking.
However I’m in the process of adding
acts_as_list to a
Photo model and I’m unsure of how to translate the process of updating a photo’s position in its owning
acts_as_list uses a
position column on
Photo to track the postion of the
Photo within the gallery, allowing this position to be manipulated using methods like
move_higher and atomatically reordering photos accordingly.
Within My Gallery’s
show view, I display a list of its photos, ordered by
postion. For each photo I have an up and down arrow for moving that photo up or down in order.
In most examples I’ve seen that hook
acts_as_list in to a Controller, there is an additional
sort action on an existing controller. This doesn’t feel right to me.
The best solution I’ve come up with is to create a
PhotoListController with a single
update action that receives a PATCH containing the photo’s id and an offset. The action would use
acts_as_list's API to reorder the photos and redirect to the referrer. However, this doesn’t feel right either.
How would you suggest handling this situation?