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.
 
 
 
 
 

43 lines
974 B

class Cdao::Jurisprudence < Cdao::Base
self.table_name = "jurisprudences"
has_many :doctrines, as: :document, dependent: :restrict_with_error
alias_attribute :doc_date, :docdate
def subjects
doctrines.map(&:subjects).flatten.uniq
end
def subject_ids
subjects.map(&:id)
end
searchable do
text :reference_number, stored: true
text :title, stored: true
text :short_title, stored: true
string :reference_number
string :title do
(title.present? ? title.first(32760).strip : short_title).titleize
end
string :short_title do
(short_title.presence || title.first(32760).strip).titleize
end
date :doc_date
date :search_doc_date do
doc_date.presence || Date.new(year.presence || 0)
end
integer :id
integer :year
integer :search_year do
year.present? && year > 0 ? year : (doc_date.try :year)
end
integer :subject_ids, multiple: true
boolean :edited
end
end