Skip to content
Snippets Groups Projects
learning_object.rb 815 B
Newer Older
class LearningObject < ActiveRecord::Base
  include Metadatable
  include Reviewable
  include Sociable
  has_and_belongs_to_many :topics

  has_many :collection_items, as: :collectionable
  has_many :collections, through: :collection_items

  has_many :complaints
  has_many :attachments, class_name: 'LearningObject::Attachment'
  belongs_to :publisher, polymorphic: true

  searchkick language: 'brazilian', searchable: [:name, :description, :author, :object_type]
Mateus Rambo Strey's avatar
Mateus Rambo Strey committed

  def search_data
    {
      name: name,
      description: description,
      author: author,
      object_type: object_type,
      score: score,
      published_at: published_at,
      # publisher_id: publisher.id,
      topics_name: topics.map(&:name)
    }
  end

  def categories
    get_metadata_value_of 'dc.subject.category'
  end