Added position on Enumeration model.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@800 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
479b9b5433
commit
c216ab325b
4 files changed
+67
-28
No files matched your search
@@ -0,0 +1,12 @@
|
||||
class AddEnumerationsPosition < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :enumerations, :position, :integer, :default => 1, :null => false
|
||||
Enumeration.find(:all).group_by(&:opt).each_value do |enums|
|
||||
enums.each_with_index {|enum, i| enum.update_attribute(:position, i+1)}
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :enumerations, :position
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user