Sha256: b93f6ed93c7941e2aa82ced994c6770f3e177c657c4b9d145d061e1d05ae4b1e

Contents?: true

Size: 983 Bytes

Versions: 1

Compression:

Stored size: 983 Bytes

Contents

class ManifestationRelationship < ActiveRecord::Base
  attr_accessible :parent_id, :child_id, :manifestation_relationship_type_id
  belongs_to :parent, foreign_key: 'parent_id', class_name: 'Manifestation'
  belongs_to :child, foreign_key: 'child_id', class_name: 'Manifestation'
  belongs_to :manifestation_relationship_type
  validate :check_parent
  validates_presence_of :parent_id, :child_id
  acts_as_list scope: :parent_id

  def check_parent
    if parent_id == child_id
      errors.add(:parent)
      errors.add(:child)
    end
  end
end

# == Schema Information
#
# Table name: manifestation_relationships
#
#  id                                 :integer          not null, primary key
#  parent_id                          :integer
#  child_id                           :integer
#  manifestation_relationship_type_id :integer
#  created_at                         :datetime
#  updated_at                         :datetime
#  position                           :integer
#

Version data entries

1 entries across 1 versions & 1 rubygems

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