From c9b6f03c3231fa23f245c6964b3f4d294c13bf60 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Fri, 17 Apr 2015 22:12:13 +0300 Subject: [PATCH] Introduce an association to Events from Conferences --- app/models/conference.rb | 2 ++ app/models/track.rb | 3 +++ 2 files changed, 5 insertions(+) diff --git a/app/models/conference.rb b/app/models/conference.rb index 6ec49ee..16bc384 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -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 diff --git a/app/models/track.rb b/app/models/track.rb index 7f5e7c2..3f4f010 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -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}