[phase-6]add relation to project to term and category models
This commit is contained in:
parent
5d61bef881
commit
e1ee6f8f64
@ -1,3 +1,4 @@
|
|||||||
class GlossaryCategory < ActiveRecord::Base
|
class GlossaryCategory < ActiveRecord::Base
|
||||||
has_many :terms, class_name: 'GlossaryTerm', foreign_key: 'category_id'
|
has_many :terms, class_name: 'GlossaryTerm', foreign_key: 'category_id'
|
||||||
|
belongs_to :project
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
class GlossaryTerm < ActiveRecord::Base
|
class GlossaryTerm < ActiveRecord::Base
|
||||||
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
|
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
|
||||||
|
belongs_to :project
|
||||||
end
|
end
|
||||||
|
6
db/migrate/004_add_project_to_terms_and_categories.rb
Normal file
6
db/migrate/004_add_project_to_terms_and_categories.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user