You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
926 B
40 lines
926 B
class Annotation < ApplicationRecord |
|
acts_as_list column: :rank, scope: %i[doctrine_id] |
|
|
|
belongs_to :doctrine, optional: false |
|
|
|
belongs_to :document, polymorphic: true, optional: false |
|
|
|
has_many :annotation_documents, inverse_of: :annotation, dependent: :destroy |
|
accepts_nested_attributes_for :annotation_documents, allow_destroy: true |
|
|
|
has_many :annotation_annomarks, dependent: :destroy |
|
has_many :annomarks, through: :annotation_annomarks |
|
|
|
def documents |
|
annotation_documents.collect(&:document) |
|
end |
|
|
|
def add_document(document) |
|
record = annotation_documents.new |
|
record.document = document |
|
record.save |
|
end |
|
|
|
def remove_document(document) |
|
annotation_documents.find_by(document_id: document.id).destroy |
|
end |
|
|
|
def citing_document_ids |
|
documents.map(&:id) |
|
end |
|
|
|
searchable do |
|
integer :document_id |
|
integer :doctrine_id |
|
|
|
text :phil_rep |
|
|
|
string :phil_rep |
|
end |
|
end
|
|
|