Skip to content

Commit

Permalink
fix relation for cascading deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansing committed Oct 17, 2024
1 parent b6fb2e7 commit 856e5ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/models/compound_form/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

class CompoundForm::Base < ApplicationRecord
class_attribute :rdf_namespace, :rdf_predicate

self.rdf_namespace = 'iqvoc'
self.rdf_predicate = 'compoundFrom'

self.table_name ='compound_forms'

belongs_to :domain, :class_name => 'Label::Base', :foreign_key => 'domain_id'
belongs_to :domain,
class_name: 'Label::Base',
foreign_key: 'domain_id'

has_many :compound_form_contents,
class_name: 'CompoundForm::Content::Base',
Expand Down
9 changes: 7 additions & 2 deletions app/models/compound_form/content/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ class CompoundForm::Content::Base < ApplicationRecord

self.table_name ='compound_form_contents'

belongs_to :compound_form, :class_name => 'CompoundForm::Base', :foreign_key => 'compound_form_id'
belongs_to :label, :class_name => 'Label::Base', :foreign_key => 'label_id'
belongs_to :compound_form,
class_name: 'CompoundForm::Base',
foreign_key: 'compound_form_id'

belongs_to :label,
class_name: 'Label::Base',
foreign_key: 'label_id'

def self.label_published
includes(:label).references(:labels).merge(Label::Base.published)
Expand Down
3 changes: 1 addition & 2 deletions app/models/concerns/compound_forms_label_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ module CompoundFormsLabelExtensions

has_many :compound_form_contents,
through: :compound_forms,
class_name: "CompoundForm::Content::Base",
dependent: :destroy
class_name: "CompoundForm::Content::Base"

validate :compound_form_contents_size
validate :compound_form_contents_languages
Expand Down

0 comments on commit 856e5ad

Please sign in to comment.