# Acts\_as\_list help

**URL:** <https://www.ruby-forum.com/t/acts-as-list-help/116363>\
**Category:** Rails\
**Created:** [October 4, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/acts-as-list-help/116363 "2007-10-04T21:05:27Z")\
**Posts on this page:** 2\
**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, 9:05pm UTC](https://www.ruby-forum.com/t/acts-as-list-help/116363/1 "2007-10-04T21:05:27Z")

</div>

Thanks for the help all,

I have switched to using acts as list

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

process\_detail  
belongs\_to process  
acts\_as\_list :scope =\> :process\_id

and I can view as a list. Thanks

Now I am working on, if data is entered into the and a position is  
specified, I need to enter in this data into that particular position  
and move the rest of the data down.

for example I have a list with 5 steps  
1  
2  
3  
4  
5  
and I insert a step with a position of 2 i want it to insert it into  
two and move all the other ones down one(increment the position)  
1  
2 (new Record)  
3(was 2)  
4(was 3)  
5(was 4)  
6(was 5)  
but what i get is  
1  
2  
3  
4  
5  
6 \<= new record

I will be searching the forums but if the is an easy way to do this  
please let me know.

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, 9:27pm UTC](https://www.ruby-forum.com/t/acts-as-list-help/116363/2 "2007-10-04T21:27:40Z")

</div>

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

> 4  
> 1  
> 2  
> 3  
> 4  
> 5  
> 6 \<= new record
> 
> I will be searching the forums but if the is an easy way to do this  
> please let me know.

How are you inserting it? If you are setting the position field  
directly that won’t work, the list elements are always added to the  
bottom via a before\_create callback. I think you need to create it  
and then call the insert\_at method on the model object to move it.

–  
Rick DeNatale

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