Sortable List

Hi,

I am trying to get a sortable list working using the method oulined on
this page:

http://techsutra.blogspot.com/2006/09/actsaslist-in-ruby-on-rails.html

I have the list displaying on my page but when I drag and drop and item
nothing happens. When I look at the log no action has been taken at all.

It seems as though when I drag and drop the item the update_positions
code is not being run.

Scott

development.log is your friend - it will tell you exactly where the site
stops working. Things also need to show us:

  1. the method
  2. the view
  3. relevant portion of development.log

***** The View *****

    <% @pages.each do |list| %>
  • "><%= page.name %>
  • <% end %>
<%= sortable_element('sortable_list', :update => 'pages', :complete => visual_effect(:highlight, 'sortable_list'), :url => {:action => :update_positions}) %>

***** The Methods *****

def update_positions
params[:sortable_list].each_with_index do |id, position|
Page.update(id, :position => position+1)
end
@pages = Page.find(:all, :order => :position )
render :layout => false , :action => :reorder
end

def reorder
@pages = Page.find(:all, :order => :position )
end

***** development.log *****
When I drag and drop the list items nothing happens in this log file.

***** The Model *****
acts_as_list :order => :position

***** Notes *****
I have included all required javascript files and everything seems to be
set up properly just the update_positions method isn’t run when I move
an item

Scott