Sha256: bf970f8b8129453376787bb3fa7d9d307c990361bb0021a83b67414b3b56729f

Contents?: true

Size: 769 Bytes

Versions: 1

Compression:

Stored size: 769 Bytes

Contents

class WorkHasSubject < ActiveRecord::Base
  attr_accessible :subject_id, :work_id, :position

  has_paper_trail

  belongs_to :subject
  belongs_to :work, :class_name => 'Manifestation'

  validates_presence_of :work, :subject #, :subject_type
  validates_associated :work, :subject
  validates_uniqueness_of :subject_id, :scope => :work_id
  after_save :reindex
  after_destroy :reindex

  acts_as_list :scope => :work_id

  def reindex
    work.try(:index)
    subject.try(:index)
  end
end

# == Schema Information
#
# Table name: work_has_subjects
#
#  id           :integer          not null, primary key
#  subject_id   :integer
#  subject_type :string(255)
#  work_id      :integer
#  position     :integer
#  created_at   :datetime
#  updated_at   :datetime
#

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
enju_trunk_subject-1.0.4 app/models/work_has_subject.rb