开发者

How to make the records movable? [closed]

开发者 https://www.devze.com 2023-04-04 06:19 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

In rails 3.1

I want to make the db records movables, with a Move up and a Move down link in ecah one. For example, if I have 4 records:

Title 1 [up] [开发者_JS百科down]

Title 2 [up] [down]

Title 3 [up] [down]

Title 4 [up] [down]

I could click in the Title 3's up link and the new table would be:

Title 1 [up] [down]

Title 3 [up] [down]

Title 2 [up] [down]

Title 4 [up] [down]


Add an Order field to the Table. Then when the person clicks the move up or move down, add or subtract 1 from that field. Make sure this field doesn't go below 0 or above the number of entries - 1 in your table. When you wan't to display these fields in order, just order them by this field.

Moving rows 'up and down' in a database (SQL query help)

0

精彩评论

暂无评论...
验证码 换一张
取 消