Displaying 1 result from an estimated 1 matches for "find_by_loc".
Did you mean:
find_by_foo
2006 Feb 09
1
How to reorder rows in a table?
Hi,
I have a link table with a location field, here is the code I wrote to
reorder the rows
# move_up action in links controller
def move_up
current_link = Link.find(params[:id])
current_link.location -= 1
current_link.save
same_link = Link.find_by_location(current_link.location)
same_link.location += 1
same_link.save
redirect_to :action => ''list''
end
But it does not work always, can''t figure it out.
What may be the problem?
Is there a better way to do this?
Thanks