Created
October 12, 2009 09:21
-
-
Save tejo/208281 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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