Hi While debugging the problem I reported earlier as :- "destroy list item with dependents problem", I have discovered that remove_from_list is being called twice by the Rails framework. The framework list code:- C:\ruby\lib\ruby\gems\1.8\gems\activerecord-1.9.1\lib\active_record\acts \list.rb contains a callback :- after_destroy :remove_from_list which should result in an automatic call to remove_from_list every time my code destroys a list record (I think). But the log file clearly shows that remove_from_list is called twice:- [4;35mTodo Destroy (0.000000)[0;37mDELETE FROM todos WHERE id = 318 [4;33mTodo Update (0.000000)[1;37mUPDATE todos SET position = (position - 1) WHERE 1 = 1 AND position > 3 [4;35mTodo Update (0.000000)[0;37mUPDATE todos SET position = (position - 1) WHERE 1 = 1 AND position > 3 This explains why the positions are all screwed up after a destroy. If I destroy record 3 then 1,2,3,4,5 initial positions 1,2, 3,4 after remove_from_list called once (what is desired) 1,2, 3,3 after remove_from_list called twice (what I get) I tried commenting out the callback declaration and this results in 0 calls to remove_from_list so this bug would appear to be in the callback mechanism. Peter (Rails 11.1 ,XP, MySQL)
Seems to be fixed in the latest version of Rails 0.12.0 -----Original Message----- From: Cutting Peter Sent: den 18 april 2005 16:38 To: ''rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org'' Subject: remove_from_list called twice bug Hi While debugging the problem I reported earlier as :- "destroy list item with dependents problem", I have discovered that remove_from_list is being called twice by the Rails framework. The framework list code:- C:\ruby\lib\ruby\gems\1.8\gems\activerecord-1.9.1\lib\active_record\acts \list.rb contains a callback :- after_destroy :remove_from_list which should result in an automatic call to remove_from_list every time my code destroys a list record (I think). But the log file clearly shows that remove_from_list is called twice:- [4;35mTodo Destroy (0.000000)[0;37mDELETE FROM todos WHERE id = 318 [4;33mTodo Update (0.000000)[1;37mUPDATE todos SET position = (position - 1) WHERE 1 = 1 AND position > 3 [4;35mTodo Update (0.000000)[0;37mUPDATE todos SET position = (position - 1) WHERE 1 = 1 AND position > 3 This explains why the positions are all screwed up after a destroy. If I destroy record 3 then 1,2,3,4,5 initial positions 1,2, 3,4 after remove_from_list called once (what is desired) 1,2, 3,3 after remove_from_list called twice (what I get) I tried commenting out the callback declaration and this results in 0 calls to remove_from_list so this bug would appear to be in the callback mechanism. Peter (Rails 11.1 ,XP, MySQL)