search for: insert_at

Displaying 4 results from an estimated 4 matches for "insert_at".

2006 Apr 03
2
Fast way of finding new position for model object?
...ct''s position. Right now this is done with the following method: def update_position position = nil Bug.find(:all, :order => "votes_count DESC, id ASC").each_with_index{ |bug,i| if bug.id == self.id position = i break end } self.insert_at(position) end Basically, find all of the bugs in the order in which they''re wanted and then iterate through each until the new position of this bug is found. When it''s found, save the position, break out of the loop and insert the current model into the correct position. Unfor...
2008 Mar 10
0
Sortables, acts_as_list and performance
...rdering 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 recalculat...
2007 Jul 12
1
acts as list -- adding or moving new item to new location
right now i''m adding an item to my ''list'' but i''m unsure how to move it to a certain spot in the list. specifically i want to put it at the bottom of the list. i assumed that if i did something like parent.children << new_child then the ''position'' field in the child table would be given some sensible default by rails but instead
2006 Feb 22
9
acts_as_habtm_list plugin
I''d like to announce acts_as_habtm_list plugin for rails. acts_as_habtm_list is a Ruby on Rails plugin, that can manage ordered lists through a join-table. It is providing almost the same Api as acts_as_list. The position column has to be defined in the join table. You can find additional information at: http://www.inlet-media.de/acts_as_habtm_list/ Install it executing this command