Sha256: 1d72ae26c47132d1101b6cc15fbd3b4025c4652b61f899fe8d12b2baf9b1abad

Contents?: true

Size: 821 Bytes

Versions: 1

Compression:

Stored size: 821 Bytes

Contents

class Create < ActiveRecord::Base
  attr_accessible :agent_id, :work_id, :create_type_id, :position
  belongs_to :agent
  belongs_to :work, class_name: 'Manifestation', foreign_key: 'work_id', touch: true
  belongs_to :create_type

  validates_associated :agent, :work
  validates_presence_of :agent_id, :work_id
  validates_uniqueness_of :work_id, scope: :agent_id
  after_save :reindex
  after_destroy :reindex

  acts_as_list scope: :work

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

# == Schema Information
#
# Table name: creates
#
#  id             :integer          not null, primary key
#  agent_id       :integer          not null
#  work_id        :integer          not null
#  position       :integer
#  created_at     :datetime
#  updated_at     :datetime
#  create_type_id :integer
#

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
enju_biblio-0.1.0.pre63 app/models/create.rb