Noob needs help updating a sortable table in the database

Hi, I am brand new to Rails and I love it, but I am stuck on something
I just can’t figure out.

I have table in my database of Pages which are listed in the admin
view in an HTML table.

Each page has

The HTML table displays:

The HTML table has some jQuery attached to it that allows me to sort
the rows up and down, and then updates the text inside the Page_order
table cells to be in numerical order. In other words:

| Title | Page Order |

| About | 0 |
| Contact | 1 |
| Pricing | 2 |

Say you want Contact to be at the bottom (since the nav menu on the
web site is ordered by page_order). So you drag Pricing above Contact
and you’ll see:

| Title | Page Order |

| About | 0 |
| Pricing | 1 |
| Contact | 2 |

This I can make work. The part I don’t know how to do is send an ajax
request to update the database and change the page_order values to
reflect the changes.

Can someone help?

Why not defer making changes at the DB level until the person is done
with the page. Ye olde Save or Cancel (or just navigate away).

An Ajax request and DB update per “fiddle” with a row seems overdone to
me, but if your interface doesn’t use an explicit “save” button or
something similar, then it could work.

As for the Ajax part, I haven’t ventured there myself yet.

Well I’m trying to do it from the list action, so there is no save
button, though I could do that. It’s not a bad idea. Maybe enable/
reveal a link_to or button_to after a change is made?