Forum: Ruby on Rails Drag and drop sortable list woes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F779209a7f02c754eda7b505898347f9?d=identicon&s=25 Rob Balfour (robtotheb)
on 2006-06-05 14:50
Well I have it dragging and dropping but its not saving!

 def sort
    @prices = Price.find(params[:id])
    @prices.each do |@price|
      @price.position = params['price'].index( + 1
  render :nothing => true

Current error in the view after dropping is -

undefined method `each' for #<Price:0xb74ec4ac>

/app/controllers/admin_controller.rb:171:in `sort'

Parameters: {"price"=>["2", "3", "1"], "id"=>"3"}
Ed5307c79ba5b415b1ddfee48319099b?d=identicon&s=25 Ioana Kanda (Guest)
on 2006-06-05 22:43
(Received via mailing list)
Price.find(params[:id]) doesn;t return an array, it's just an Price
Maybe u want smth like:
         @price = Price.find(params[:id]).position
         @price.update_attribute(:position, params['price'].index(@ + 1)
This topic is locked and can not be replied to.