diff --git a/app/models/glossary_category.rb b/app/models/glossary_category.rb index b48306a..43bbade 100644 --- a/app/models/glossary_category.rb +++ b/app/models/glossary_category.rb @@ -1,3 +1,4 @@ class GlossaryCategory < ActiveRecord::Base has_many :terms, class_name: 'GlossaryTerm', foreign_key: 'category_id' + belongs_to :project end diff --git a/app/models/glossary_term.rb b/app/models/glossary_term.rb index 645b6f0..fd087b3 100644 --- a/app/models/glossary_term.rb +++ b/app/models/glossary_term.rb @@ -1,3 +1,4 @@ class GlossaryTerm < ActiveRecord::Base belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id' + belongs_to :project end diff --git a/db/migrate/004_add_project_to_terms_and_categories.rb b/db/migrate/004_add_project_to_terms_and_categories.rb new file mode 100644 index 0000000..295e2c5 --- /dev/null +++ b/db/migrate/004_add_project_to_terms_and_categories.rb @@ -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