Forum: Ruby on Rails acts_as_list issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
tankow (Guest)
on 2008-10-30 05:24
(Received via mailing list)
The list i have defined in my acts_as_list will not let me drag the li
elements around.  I am using FF, but IE6 also fails.  Here is what i
have defined in my code:

model: listing.rb

class Listing < ActiveRecord::Base
  acts_as_list
end

view: index.rb

<h1>Listing listings</h1>

<div id="items">
<ul id="item_list">

<% for listing in @listings %>
  <li id="item_<%= listing.id %>">
    <%=h listing.name %>
    <%=h listing.completed_dt %>
    <%=h listing.position %>
  </li>
<% end %>
</ul>
</div>

<% sortable_element 'item_list', :url => { :action => "sort" }
%>

<br />

<%= link_to 'New listing', new_listing_path %>

controller: listings_controller.rb

  ...
  def sort
  params[:item_list].each_index do |i|
    item = Listing.find(params[:item_list][i])
      item.position = i
      item.save
    end
    @list = Listing.find(:all, :order => 'position')
    render :layout => false, :action => :index
  end

I also have all of the javascript includes in the layout and can see
them when i view source of the page.

What am i missing? or what is wrong with the code?

Thanks
Phil
tankow (Guest)
on 2008-11-02 04:33
(Received via mailing list)
problem was the invalidauthenticitytoken
This topic is locked and can not be replied to.