[Rails] Acts As List bug: changing value of a scope attribute

Gareth Adams gareth.adams at gmail.com
Mon Aug 14 09:57:57 GMT 2006


Hi,

I've just found out about this issue and it seems dev.rubyonrails.org is down so
I thought I'd put it to the list

Say I have an acts_as_list with as associated scope:

MyObject
------
id   assoc_id   position
==   ========   ========
 1          1          1
 2          1          2
 3          1          3
 4          2          1
 5          3          1

If I alter one of my objects:

MyObject.find(2).assoc = Assoc.find(2) # or a similar line changing the id

all that seems to happen is the foreign key id changes - I'm left with

id   assoc_id   position
==   ========   ========
 1          1          1
 2          2          2
 3          1          3

and reordering then stops working because the positions for Assoc 1 aren't
consecutive.

Is this something people have thought about before? I'd be surprised if it
hasn't come up at all.

Thanks,
Gareth



More information about the Rails mailing list