Hi!
I have a reordering feature for one of my models. It''s done with
Sortables JS component that sends an Ajax request with a hash of new
positions for each item after reordering, with the following action
that processes it:
def reorder
params[:pos].each do |id, pos|
@user.activities.find(id).insert_at(pos)
end
head :ok
end
I''m using acts_as_list to recalculate positions.
Everything works, but I have a problem: for EVERY activity that was
moved there are 5 requests to the database (1 select and 4 updates,
which in their turn are quite CPU-intensive because position
recalculation involves updating most of the list items).
Did someone solve a similar problem? Any advices on making reordering
not so resource-hungry and slow?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---