ADD a tree structure to model ProjectCategory
This commit is contained in:
parent
d16faf40af
commit
edd8780607
2
Gemfile
2
Gemfile
|
@ -51,6 +51,8 @@ gem 'kaminari'
|
|||
gem 'elasticsearch-model'
|
||||
gem 'elasticsearch-rails'
|
||||
|
||||
gem 'ancestry'
|
||||
|
||||
#rails 3.2.22.2 bug
|
||||
# gem "test-unit", "~>3.0"
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# 项目类别
|
||||
class ProjectCategory < ActiveRecord::Base
|
||||
attr_accessible :name, :position, :projects_count
|
||||
has_ancestry
|
||||
|
||||
has_many :projects
|
||||
end
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AddAncestryToProjectCategories < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :project_categories, :ancestry, :string
|
||||
add_index :project_categories, :ancestry
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20191107015025) do
|
||||
ActiveRecord::Schema.define(:version => 20191107031711) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1980,8 +1980,11 @@ ActiveRecord::Schema.define(:version => 20191107015025) do
|
|||
t.integer "projects_count", :default => 0
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "ancestry"
|
||||
end
|
||||
|
||||
add_index "project_categories", ["ancestry"], :name => "index_project_categories_on_ancestry"
|
||||
|
||||
create_table "project_infos", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.integer "user_id"
|
||||
|
|
Loading…
Reference in New Issue