# Magic Field Names - "position"

**URL:** <https://www.ruby-forum.com/t/magic-field-names-position/57106>\
**Category:** Rails\
**Created:** [April 7, 2006, 8:17am UTC](https://www.ruby-forum.com/t/magic-field-names-position/57106 "2006-04-07T08:17:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![d6veteran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@d6veteran](https://www.ruby-forum.com/u/d6veteran)\
**Post date:** [April 7, 2006, 8:17am UTC](https://www.ruby-forum.com/t/magic-field-names-position/57106/1 "2006-04-07T08:17:11Z")

</div>

What does the Magic Field Name position do?

I was looking here:  
[http://wiki.rubyonrails.com/rails/pages/MagicFieldNames](http://wiki.rubyonrails.com/rails/pages/MagicFieldNames)

And unfortunately that documentation is incomplete.

Thanks.

---

<div class="post-metadata">

**Author:** ![d6veteran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@d6veteran](https://www.ruby-forum.com/u/d6veteran)\
**Post date:** [April 7, 2006, 8:37am UTC](https://www.ruby-forum.com/t/magic-field-names-position/57106/2 "2006-04-07T08:37:53Z")

</div>

Arch S. wrote:

> What does the Magic Field Name position do?
> 
> I was looking here:  
> [Peak Obsession](http://wiki.rubyonrails.com/rails/pages/MagicFieldNames)
> 
> And unfortunately that documentation is incomplete.
> 
> Thanks.

When using acts\_as\_list, it keeps track of the position of the item on  
the list.

joey\_\_

---

<div class="post-metadata">

**Author:** ![d6veteran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@d6veteran](https://www.ruby-forum.com/u/d6veteran)\
**Post date:** [April 7, 2006, 8:43am UTC](https://www.ruby-forum.com/t/magic-field-names-position/57106/3 "2006-04-07T08:43:23Z")

</div>

joey\_\_ wrote:

> Arch S. wrote:
> 
> > What does the Magic Field Name position do?
> > 
> > I was looking here:  
> > [Peak Obsession](http://wiki.rubyonrails.com/rails/pages/MagicFieldNames)
> > 
> > And unfortunately that documentation is incomplete.
> > 
> > Thanks.
> 
> When using acts\_as\_list, it keeps track of the position of the item on  
> the list.
> 
> joey\_\_

Can the list be specific to a belongs\_to relationship?

---

<div class="post-metadata">

**Author:** ![d6veteran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@d6veteran](https://www.ruby-forum.com/u/d6veteran)\
**Post date:** [April 7, 2006, 5:55pm UTC](https://www.ruby-forum.com/t/magic-field-names-position/57106/4 "2006-04-07T17:55:45Z")

</div>

Alex Y. wrote:

> Alex Y. wrote:
> 
> > > > >
> > > 
> > > Can the list be specific to a belongs\_to relationship?
> > 
> > Yes - use :order =\> :position in the belongs\_to.
> 
> D’oh… Must not post before tea…
> 
> class Parent \< AR::Base  
> has\_many :children, :order =\> :position  
> end
> 
> class Child \< AR::Base  
> acts\_as\_list, :scope =\> :parent  
> belongs\_to :parent, :order =\> :position  
> end

Ahhh, that is cool.

One more question: what is the difference between specifying the :order  
in belongs\_to vs. has\_many? I would think you only need specify :order  
in the has\_many declaration. ??

---

<div class="post-metadata">

**Author:** ![d6veteran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@d6veteran](https://www.ruby-forum.com/u/d6veteran)\
**Post date:** [April 7, 2006, 9:27am UTC](https://www.ruby-forum.com/t/magic-field-names-position/57106/5 "2006-04-07T09:27:04Z")

</div>

Alex Y. wrote:

> > > >
> > 
> > Can the list be specific to a belongs\_to relationship?
> 
> Yes - use :order =\> :position in the belongs\_to.

D’oh… Must not post before tea…

class Parent \< AR::Base  
has\_many :children, :order =\> :position  
end

class Child \< AR::Base  
acts\_as\_list, :scope =\> :parent  
belongs\_to :parent, :order =\> :position  
end

---

<div class="post-metadata">

**Author:** ![d6veteran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@d6veteran](https://www.ruby-forum.com/u/d6veteran)\
**Post date:** [April 7, 2006, 6:36pm UTC](https://www.ruby-forum.com/t/magic-field-names-position/57106/6 "2006-04-07T18:36:13Z")

</div>

Arch S. wrote:

> > 
> 
> Ahhh, that is cool.
> 
> One more question: what is the difference between specifying the :order  
> in belongs\_to vs. has\_many? I would think you only need specify :order  
> in the has\_many declaration. ??  
> Just looking at it, I can’t think where it would be useful, but it’s in  
> the docs as a supported option, so I suppose it must do something 🙂

---

<div class="post-metadata">

**Author:** ![d6veteran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/94ad74/32.png) [@d6veteran](https://www.ruby-forum.com/u/d6veteran)\
**Post date:** [April 7, 2006, 9:17am UTC](https://www.ruby-forum.com/t/magic-field-names-position/57106/7 "2006-04-07T09:17:47Z")

</div>

Arch S. wrote:

> > > Thanks.
> > 
> > When using acts\_as\_list, it keeps track of the position of the item on  
> > the list.
> > 
> > joey\_\_
> 
> Can the list be specific to a belongs\_to relationship?  
> Yes - use :order =\> :position in the belongs\_to.
