Fix order in structure
This commit is contained in:
1 parent
5b289bc1d2
commit
fa83dbf791
3 files changed
+17
-10
No files matched your search
@@ -350,4 +350,16 @@ namespace :migrate do
|
||||
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/gallery/gallery.json").read).save
|
||||
end
|
||||
|
||||
task :reorder_items => :environment do
|
||||
reorder_children(Item.root)
|
||||
end
|
||||
|
||||
def reorder_children(parent)
|
||||
parent.children.each_with_index do |child, i|
|
||||
child.position = i
|
||||
child.save
|
||||
reorder_children(child) if child.children
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user