Sha256: 12cc34fff535b9f8a539631b6f4171770c5f076bd51f40ea77660b482e45d90f

Contents?: true

Size: 1.69 KB

Versions: 5

Compression:

Stored size: 1.69 KB

Contents

module Concernz
  module Event
    extend ActiveSupport::Concern
    included do
      self.primary_key = 'event_id'

      # Event is held at Venue
      belongs_to :venue, :foreign_key => :venue_id

      # Event issued Ticket
      has_many :tickets, :class_name => 'Ticket', :foreign_key => :event_id, :dependent => :destroy
      has_many :seats, :through => :tickets

      validates :venue_id, :presence => true
    end
  end
end

module Concernz
  module Seat
    extend ActiveSupport::Concern
    included do
      self.primary_key = 'seat_id'

      # Seat is at Venue
      belongs_to :venue, :foreign_key => :venue_id

      # Ticket is for Seat
      has_many :tickets, :class_name => 'Ticket', :foreign_key => :seat_id, :dependent => :destroy
      has_many :events, :through => :tickets

      validates :number, :presence => true
      validates :reserve_name, :presence => true
      validates :row_code, :presence => true
      validates :venue_id, :presence => true
    end
  end
end

module Concernz
  module Ticket
    extend ActiveSupport::Concern
    included do
      # Ticket is for Event
      belongs_to :event, :foreign_key => :event_id

      # Ticket is for Seat
      belongs_to :seat, :foreign_key => :seat_id

      validates :event_id, :presence => true
      validates :seat_id, :presence => true
    end
  end
end

module Concernz
  module Venue
    extend ActiveSupport::Concern
    included do
      self.primary_key = 'venue_id'

      # Venue hosts Event
      has_many :events, :class_name => 'Event', :foreign_key => :venue_id, :dependent => :destroy

      # Venue has Seat
      has_many :seats, :class_name => 'Seat', :foreign_key => :venue_id, :dependent => :destroy
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activefacts-examples-1.9.9 rails/models/VenueSeating.models
activefacts-examples-1.9.8 rails/models/VenueSeating.models
activefacts-examples-1.8.0 rails/models/VenueSeating.models
activefacts-examples-1.7.2 rails/models/VenueSeating.models
activefacts-examples-1.7.1 rails/models/VenueSeating.models