Introduce an association to Events from Conferences

This commit is contained in:
Petko Bordjukov 2015-04-17 22:12:13 +03:00
parent 050db7d124
commit c9b6f03c32
2 changed files with 5 additions and 0 deletions

View File

@ -10,6 +10,8 @@ class Conference < ActiveRecord::Base
has_many :tracks
has_many :halls
has_many :events, through: :tracks
accepts_nested_attributes_for :tracks, :halls, reject_if: :all_blank, allow_destroy: true

View File

@ -1,5 +1,8 @@
class Track < ActiveRecord::Base
include PropositionAccepting
belongs_to :conference
has_many :events, through: :propositions, source: :proposable, source_type: Event
validates :name, presence: true
validates :color, presence: true, format: {with: /\A#?[a-f0-9]{6}\z/i}