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(@price.id.to_s)
+ 1
@price.save
end
render :nothing => true
end
Current error in the view after dropping is -
undefined method `each'' for #<Price:0xb74ec4ac>
/app/controllers/admin_controller.rb:171:in `sort''
Request
Parameters: {"price"=>["2", "3",
"1"], "id"=>"3"}
--
Posted via http://www.ruby-forum.com/.
Price.find(params[:id]) doesn;t return an array, it''s just an Price
object.
Maybe u want smth like:
@price = Price.find(params[:id]).position
@price.update_attribute(:position,
params[''price''].index(@
price.id.to_s) + 1)
--
Cheers,
ioana k&a
http://boulangerie.wordpress.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060605/269774be/attachment.html