ryanburnette / rcms

My learning rails project and long term Rails CMS. Not ready for primetime.
0 stars 0 forks source link

Drag/drop order for Pages #18

Closed ryanburnette closed 10 years ago

ryanburnette commented 10 years ago

I'm going to work on a drag/drop interface for ordering pages. I'm confident that I can work out the front-end stuff.

For keeping track of orders of objects I really like this ranked-model Gem I read about in this post about sorting in Rails. I had considered writing the orders sequentially each time a save happened, but that would be a lot of expensive writing if there were a lot of items. I also considered serializing the order in a single field, but that doesn't work well when new objects are added.

This Gem is way smarter about it. It spreads the numbers out a ton so it usually will only do one write to manage order, but it can rewrite multiple items if it needs to.

ryanburnette commented 10 years ago

After a bit of jQuery UI this now works. I still want to review to make sure I'm using decent methods to go about this. https://github.com/ryanburnette/rcms/commit/08ab5b327af6f792366ed6c7cb8ec4821e8f6abe