Sha256: f1de13475b7a2a4943f70dd8d38246e36fe10ca937293adea6a01251e9898677
Contents?: true
Size: 500 Bytes
Versions: 1
Compression:
Stored size: 500 Bytes
Contents
class Person < ActiveRecord::Base has_and_belongs_to_many_with_deferred_save :rooms, :validate => true attr :do_extra_validation, true validate :extra_validation, :if => :do_extra_validation def extra_validation rooms.each do |room| this_room_unsaved = rooms_without_deferred_save.include?(room) ? 0 : 1 if room.people.size + this_room_unsaved > room.maximum_occupancy errors.add :rooms, "This room has reached its maximum occupancy" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
deferred_associations-0.5.4 | spec/models/person.rb |