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.
Rob B. (Guest)
on 2006-06-05 16: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"}
Ioana K. (Guest)
on 2006-06-06 00: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.