[phase-6]add relation to project to term and category models

This commit is contained in:
Toru Takahashi 2018-05-12 14:26:43 +09:00 committed by TAKAHASHI,Toru
parent 5d61bef881
commit e1ee6f8f64
3 changed files with 8 additions and 0 deletions

View File

@ -1,3 +1,4 @@
class GlossaryCategory < ActiveRecord::Base
has_many :terms, class_name: 'GlossaryTerm', foreign_key: 'category_id'
belongs_to :project
end

View File

@ -1,3 +1,4 @@
class GlossaryTerm < ActiveRecord::Base
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
belongs_to :project
end

View File

@ -0,0 +1,6 @@
class AddProjectToTermsAndCategories < ActiveRecord::Migration[5.1]
def change
add_reference :glossary_terms, :project, foreign_key: true
add_reference :glossary_categories, :project, foreign_key: true
end
end