Merge pull request #1039 from okriuchykhin/ok_SCI_1697

Improve connections between repository models [SCI-1697]
This commit is contained in:
okriuchykhin 2018-03-19 16:42:55 +01:00 committed by GitHub
commit d906baff61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -3,8 +3,10 @@ class MyModuleRepositoryRow < ApplicationRecord
foreign_key: 'assigned_by_id',
class_name: 'User',
optional: true
belongs_to :repository_row, optional: true
belongs_to :my_module, optional: true
belongs_to :repository_row,
optional: true,
inverse_of: :my_module_repository_rows
belongs_to :my_module, optional: true, inverse_of: :my_module_repository_rows
validates :repository_row, :my_module, presence: true
validates :repository_row, uniqueness: { scope: :my_module }

View file

@ -1,7 +1,9 @@
class RepositoryCell < ActiveRecord::Base
belongs_to :repository_row
belongs_to :repository_column
belongs_to :value, polymorphic: true, dependent: :destroy
belongs_to :value, polymorphic: true,
inverse_of: :repository_cell,
dependent: :destroy
belongs_to :repository_text_value,
(lambda do
where(repository_cells: { value_type: 'RepositoryTextValue' })