Ill keep it brief. Dragging an item is working but dropping and
updating the list gives me this error -
NoMethodError in AdminController#sort
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each
#{RAILS_ROOT}/app/controllers/admin_controller.rb:171:in `sort''
# My view -
<ul id="price">
<% @prices.each do |@price| %>
<li id="price_<%= @price.id %>">
<%= @price.service %> <%= @price.price %>
</li>
<% end %>
</ul>
<p id="list-info"></p>
<%= sortable_element ''price'',
:update => ''list-info'',
:url => { :action => "sort", :id => @price },
:complete => visual_effect(:highlight, ''pricelist'')
%>
# Controller -
def sort
@price = Price.find(params[:price])
@prices.each do |@price|
@price.position = params[''price''].index(@price.id.to_s) +
1
@price.save
end
render :nothing => true
end
# Model -
class Price < ActiveRecord::Base
belongs_to :user
acts_as_list :scope => :user
end
--
Posted via http://www.ruby-forum.com/.