Sha256: 6a38458807bfd8e7e906a5c7e68dabc3161f77e055a51c5cf5e9d90b9c320a4d

Contents?: true

Size: 817 Bytes

Versions: 5

Compression:

Stored size: 817 Bytes

Contents

class Realize < ActiveRecord::Base
  belongs_to :agent
  belongs_to :expression, class_name: 'Manifestation', foreign_key: 'expression_id', touch: true
  belongs_to :realize_type, optional: true

  validates_associated :agent, :expression
  validates_presence_of :agent, :expression
  validates_uniqueness_of :expression_id, scope: :agent_id
  after_save :reindex
  after_destroy :reindex

  acts_as_list scope: :expression

  def reindex
    agent.try(:index)
    expression.try(:index)
  end
end

# == Schema Information
#
# Table name: realizes
#
#  id              :integer          not null, primary key
#  agent_id        :integer          not null
#  expression_id   :integer          not null
#  position        :integer
#  created_at      :datetime
#  updated_at      :datetime
#  realize_type_id :integer
#

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
enju_biblio-0.3.2 app/models/realize.rb
enju_biblio-0.3.1 app/models/realize.rb
enju_biblio-0.3.0 app/models/realize.rb
enju_biblio-0.3.0.rc.1 app/models/realize.rb
enju_biblio-0.3.0.beta.2 app/models/realize.rb