Sha256: 9519fffb55ac30a808bd16f695d26b03d376985ecbf262e699ae70844bb457d1

Contents?: true

Size: 846 Bytes

Versions: 3

Compression:

Stored size: 846 Bytes

Contents

class Create < ActiveRecord::Base
  attr_accessible :patron_id, :work_id, :create_type_id
  belongs_to :patron
  belongs_to :work, :class_name => 'Manifestation', :foreign_key => 'work_id'
  belongs_to :create_type

  validates_associated :patron, :work
  validates_presence_of :patron_id, :work_id
  validates_uniqueness_of :work_id, :scope => :patron_id
  after_save :reindex
  after_destroy :reindex

  acts_as_list :scope => :work

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


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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
enju_biblio-0.1.0.pre3 app/models/create.rb
enju_biblio-0.1.0.pre2 app/models/create.rb
enju_biblio-0.1.0.pre app/models/create.rb