This plugin enables those slicker-than-snot ajax drag-drop sortable elements on your active-scaffold page, with so little configuration you almost get it for free.
You’ll need at least ActiveScaffold 1.1.1 to use this, and probably rails 2.0
# rails 2.1 script/plugin install git://github.com/timcharper/active_scaffold_sortable.git # rails 2.0 git clone git://github.com/timcharper/active_scaffold_sortable.git vendor/plugins/active_scaffold_sortable
Create a model with a column called “position”:
# app/models/entry.rb # id integer # title string(255) # birthday date # position integer class Entry < ActiveRecord::Base end
Create your scaffold controller
# app/controllers/entries_controller.rb class EntryController < ApplicationController active_scaffold :entries do |config| config.actions << :sortable end end
and layout
# app/views/layouts/application.rhtml <html> <head> <title>active scaffold demo application</title> <%= javascript_include_tag :defaults %> <%= active_scaffold_includes %> </head> <body> <%= yield %> </body> </html>
Hah! There is no step 3! Unless, of course, something goes wrong.
If you’d like to use a different column name, put this line in your controller:
... active_scaffold :entries do |config| config.sortable.column = :position end ...
If you have issues installing the plugin, post to the Active Scaffold list.
Fork, hack, push, and request a pull:
http://gitorious.org/projects/active_scaffold_sortable
Contact me:
Tim Harper – irb(main):001:0> ( ‘tim_see_harperATgmail._see_om’.gsub(‘see’, ‘c’).gsub(‘AT’, ‘@’) )