# Is 'position' a magical field?

**URL:** <https://www.ruby-forum.com/t/is-position-a-magical-field/129316>\
**Category:** Rails\
**Created:** [February 16, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/is-position-a-magical-field/129316 "2008-02-16T17:20:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [February 16, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/is-position-a-magical-field/129316/1 "2008-02-16T17:20:27Z")

</div>

I’m looking at the typo (blog software) source. The categeries table  
has a position field which holds the order that the categories should  
appear on the blog. The field appears automagically populated when  
creating a new record or deleting an existing record, i.e., when a new  
category is added, its position is set to 1+max(position), and when a  
category is deleted, all the positions are reordered to  
1…numberofrecords. But I don’t see how or where this is done.

In category.rb there’s a method to reorder the categories, but this is  
not called either on new or destroy.

I put a position field in my own table, but it’s always nil. I’m  
stumped.

---

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [February 16, 2008, 5:26pm UTC](https://www.ruby-forum.com/t/is-position-a-magical-field/129316/2 "2008-02-16T17:26:56Z")

</div>

On Feb 16, 2008, at 17:19 , rubynuby wrote:

> I’m looking at the typo (blog software) source. The categeries table  
> has a position field which holds the order that the categories should  
> appear on the blog. The field appears automagically populated when  
> creating a new record or deleting an existing record, i.e., when a new  
> category is added, its position is set to 1+max(position), and when a  
> category is deleted, all the positions are reordered to  
> 1…numberofrecords. But I don’t see how or where this is done.

acts\_as\_list ?

---

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [February 16, 2008, 6:04pm UTC](https://www.ruby-forum.com/t/is-position-a-magical-field/129316/3 "2008-02-16T18:04:34Z")

</div>

D’oh! Somehow I missed that. It’s only the first line in the  
model 🙂

noob is as noob does! thanks
