Sha256: 3c375f4f1d981d0303301737f676f001a449891cd0265957176596a0065e962e

Contents?: true

Size: 500 Bytes

Versions: 3

Compression:

Stored size: 500 Bytes

Contents

class RoomAssignment < ActiveRecord::Base
  self.primary_keys = :student_id, :dorm_id, :room_id
  belongs_to :student
  belongs_to :room, :foreign_key => [:dorm_id, :room_id], :primary_key => [:dorm_id, :room_id]
  validates :student_id, uniqueness: {
    conditions: ->(record) {
      where(student_id: record.student_id) # enough just to exercise this code path
    }
  }

  before_destroy do |record|
    puts record
  end

  after_destroy do |record|
    puts record
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
composite_primary_keys-14.0.7 test/fixtures/room_assignment.rb
composite_primary_keys-14.0.6 test/fixtures/room_assignment.rb
composite_primary_keys-14.0.5 test/fixtures/room_assignment.rb