class Cdao::Jurisprudence < Cdao::Base self.table_name = "jurisprudences" has_many :doctrines, as: :document, dependent: :restrict_with_error alias_attribute :doc_date, :docdate 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 boolean :edited end end