mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-29 11:45:18 +08:00
Merge pull request #1039 from okriuchykhin/ok_SCI_1697
Improve connections between repository models [SCI-1697]
This commit is contained in:
commit
d906baff61
2 changed files with 7 additions and 3 deletions
|
@ -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 }
|
||||
|
|
|
@ -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' })
|
||||
|
|
Loading…
Reference in a new issue