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.
on 2007-02-01 06:40
on 2007-02-01 20:21
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.