From b548be9c8f7d6d55dc7ddaf87d79ba1dde2ed1a3 Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Wed, 18 Dec 2019 10:29:11 +0800 Subject: [PATCH] FIX sorting to projectcategory --- ...91218022602_sort_to_project_categories_with_position.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/migrate/20191218022602_sort_to_project_categories_with_position.rb diff --git a/db/migrate/20191218022602_sort_to_project_categories_with_position.rb b/db/migrate/20191218022602_sort_to_project_categories_with_position.rb new file mode 100644 index 000000000..22a0e72cb --- /dev/null +++ b/db/migrate/20191218022602_sort_to_project_categories_with_position.rb @@ -0,0 +1,7 @@ +class SortToProjectCategoriesWithPosition < ActiveRecord::Migration[5.2] + def change + ProjectCategory.order(:updated_at).each.with_index(1) do |pc, index| + pc.update_column :position, index + end + end +end