プロジェクト

全般

プロフィール

« | » 

リビジョン e1ee6f8f

高徹 高橋 徹 さんが約6年前に追加

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

差分を表示:

app/models/glossary_category.rb
class GlossaryCategory < ActiveRecord::Base
has_many :terms, class_name: 'GlossaryTerm', foreign_key: 'category_id'
belongs_to :project
end
app/models/glossary_term.rb
class GlossaryTerm < ActiveRecord::Base
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
belongs_to :project
end
db/migrate/004_add_project_to_terms_and_categories.rb
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

他の形式にエクスポート: Unified diff