Skip to content

Instantly share code, notes, and snippets.

@tejo
Created October 12, 2009 09:21
Show Gist options
  • Select an option

  • Save tejo/208281 to your computer and use it in GitHub Desktop.

Select an option

Save tejo/208281 to your computer and use it in GitHub Desktop.
module Sortable
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def save_order(items)
items.each_with_index do |item,i|
begin
c = self.find(item.to_i)
c.position = i
c.save
rescue
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment