Sha256: b72e8e4c9fe65a020574074195cb3282a37deec95a6e208c0dbd43b72f9408e7

Contents?: true

Size: 875 Bytes

Versions: 7

Compression:

Stored size: 875 Bytes

Contents

class AgentRelationship < ActiveRecord::Base
  attr_accessible :parent_id, :child_id, :agent_relationship_type_id
  belongs_to :parent, foreign_key: 'parent_id', class_name: 'Agent'
  belongs_to :child, foreign_key: 'child_id', class_name: 'Agent'
  belongs_to :agent_relationship_type
  validate :check_parent
  validates_presence_of :parent_id, :child_id
  acts_as_list scope: :parent_id

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
enju_biblio-0.1.0.pre62 app/models/agent_relationship.rb
enju_biblio-0.1.0.pre61 app/models/agent_relationship.rb
enju_biblio-0.1.0.pre60 app/models/agent_relationship.rb
enju_biblio-0.1.0.pre59 app/models/agent_relationship.rb
enju_biblio-0.1.0.pre58 app/models/agent_relationship.rb
enju_biblio-0.1.0.pre57 app/models/agent_relationship.rb
enju_biblio-0.1.0.pre56 app/models/agent_relationship.rb