# Acts\_as\_list sorting issue

**URL:** <https://www.ruby-forum.com/t/acts-as-list-sorting-issue/84083>\
**Category:** Rails\
**Created:** [February 1, 2007, 6:40am UTC](https://www.ruby-forum.com/t/acts-as-list-sorting-issue/84083 "2007-02-01T06:40:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![deniedlates](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@deniedlates](https://www.ruby-forum.com/u/deniedlates)\
**Post date:** [February 1, 2007, 6:40am UTC](https://www.ruby-forum.com/t/acts-as-list-sorting-issue/84083/1 "2007-02-01T06:40:54Z")

</div>

Hi All,

I am using acts\_as\_list to sort photographs within photo albums.

So I have two models:

Photograph (belongs\_to :photo\_album)  
PhotoAlbum (has\_many :photographs)

Everything works great, until I update the properties of a photograph by  
linking it to a different album. acts\_as\_list is not recognizing that  
the parent\_id of my photograph has changed, thus the position field in  
my photographs table is not being updated properly.

What is the proper way to update the parent/child records when a child  
is being linked to a different parent?

Thanks in advance for your help.

---

<div class="post-metadata">

**Author:** ![deniedlates](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@deniedlates](https://www.ruby-forum.com/u/deniedlates)\
**Post date:** [February 1, 2007, 8:21pm UTC](https://www.ruby-forum.com/t/acts-as-list-sorting-issue/84083/2 "2007-02-01T20:21:13Z")

</div>

I figured this one out. When I update a child record, I compare the old  
parent\_id to the new parent\_id. If they are different, I execute a  
move\_to\_bottom command on my child record. This will push the child  
record to the bottom of the new category, and will update my position  
column automatically. Hooray for Rails and acts\_as\_list.
