Hi,
I have some images and I want to be able to drag them into the order I
want and have the database updated accordingly. I have an unordered
list elsewhere in the application that works well, but for the images
I cant get it working.
In my controller I have:
def updateorder
params[:images].each_with_index { |id,idx| ProductImage.update(id,
:display_order => idx) }
render :text => ‘Updated sort order’
end
Then my view has:
Wait for the list to flash yellow before moving another item.
<%= sortable_element ‘images’,
:tag => ‘img’,
:overlap => ‘horizontal’,
:constraint => false,
:update => ‘image-info’,
:complete => visual_effect(:highlight, ‘images’),
:url => { :controller => ‘product_images’, :action =>
“updateorder” } %>
This produces the following HTML:
Wait for the list to flash yellow before moving another item.
The update gives me no errors but there are no changes made to the
database. I have no idea why this isn’t working. Any help would be
great.
Cheers,
Jamie