# Before save infinite loop

**URL:** <https://www.ruby-forum.com/t/before-save-infinite-loop/116356>\
**Category:** Rails\
**Created:** [October 4, 2007, 7:11pm UTC](https://www.ruby-forum.com/t/before-save-infinite-loop/116356 "2007-10-04T19:11:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![whitewolfaustria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@whitewolfaustria](https://www.ruby-forum.com/u/whitewolfaustria)\
**Post date:** [October 4, 2007, 7:11pm UTC](https://www.ruby-forum.com/t/before-save-infinite-loop/116356/1 "2007-10-04T19:11:35Z")

</div>

Hi all

Heres what I am trying to do, I have a table that has a process and it  
has process\_details

process  
has\_many process\_details, foreign\_key =\> :process\_id

process\_detail  
belongs\_to process

each process has a number that is associated with it, the step it is  
1,2,3,4 . . …  
Now the steps can be changed if the process changes, for example step  
3 becomes step 1 . My algorithm is trying to update each record in  
before\_save that would need to be change to keep the ordering . (1,2  
would be change to 2,3 respectively) the problem is is that I am  
calling update in before save which initiates before save again.

if anyone has an ideas to stop the recursiveness of this call or  
another way to keep the ordering please tell me, all help is  
appreciated.

White W.

---

<div class="post-metadata">

**Author:** ![whitewolfaustria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@whitewolfaustria](https://www.ruby-forum.com/u/whitewolfaustria)\
**Post date:** [October 4, 2007, 7:18pm UTC](https://www.ruby-forum.com/t/before-save-infinite-loop/116356/2 "2007-10-04T19:18:01Z")

</div>

self.attributes[field\_name] = value - this doesnt call the before save  
method

regards  
ivor

---

<div class="post-metadata">

**Author:** ![whitewolfaustria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bbce88/32.png) [@whitewolfaustria](https://www.ruby-forum.com/u/whitewolfaustria)\
**Post date:** [October 4, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/before-save-infinite-loop/116356/3 "2007-10-04T19:30:19Z")

</div>

On 10/4/07, White W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> belongs\_to process  
> another way to keep the ordering please tell me, all help is  
> appreciated.

Stepping back from the tree to the forest.

Have you considered using acts\_as\_list?

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)
