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.
 
 
 
 
 

48 lines
1.3 KiB

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_one :library, through: :document
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
join(:library_rank, target: Cdao::Document, type: :integer, join: { from: :id, to: :document_id })
join(:search_year, target: Cdao::Document, type: :integer, join: { from: :id, to: :document_id })
join(:search_doc_date, target: Cdao::Document, type: :date, join: { from: :id, to: :document_id })
date :created_at
date :updated_at
text :phil_rep
string :phil_rep
end
end