Forum: Ruby on Rails keeping track of changes in sortable elements

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.
997433f165140d58f52b8c0d1d005dc1?d=identicon&s=25 Patrick Aljord (Guest)
on 2007-01-03 04:21
(Received via mailing list)
Hey all,
I have a sortable element list that looks like this:

<ul id="yourranking" style=" list-style-type:none;      margin:0;
<% @uranks.each do |u| %>
 <li id="item_<%= %>"> <%= u.rank %>   <%= u.item.title %> </li>
<% end %>
<p id="list-info"></p>

<%= sortable_element 'yourranking',
      :update => 'list-info',
      :complete => visual_effect(:highlight, 'yourranking'),
      :url => { :controller=>"lists",:action => "order", :listid=>
'yourranking'} %>

this is the controller code:
def order
  params[params[:listid]].each_with_index { |id,idx| Urank.update(id,
:rank => idx) }

I would like to keep track of the old ranking before the latest update

 Urank.update(id,:rank=>idx,:oldrank=><old rank before update>)

any idea how to do that?

thanx in advance

This topic is locked and can not be replied to.