Allow an event to have more than one speaker

This commit is contained in:
Petko Bordjukov 2014-10-13 16:50:16 +03:00
parent 7fb71d8cf9
commit 649c5a768c
2 changed files with 13 additions and 0 deletions

View File

@ -10,6 +10,7 @@ class Event < ActiveRecord::Base
has_one :conference, through: :track has_one :conference, through: :track
belongs_to :user # XXX: Transition to candidate_speaker belongs_to :user # XXX: Transition to candidate_speaker
belongs_to :candidate_speaker, class_name: 'User', foreign_key: 'user_id' belongs_to :candidate_speaker, class_name: 'User', foreign_key: 'user_id'
has_and_belongs_to_many :speakers, class_name: 'SpeakerProfile'
after_create :send_new_event_notification after_create :send_new_event_notification

View File

@ -0,0 +1,12 @@
class CreateEventsToSpeakersJoinTable < ActiveRecord::Migration
def up
create_join_table :events, :speaker_profiles
Event.all.each do |event|
event.speakers << event.user.speaker_profile if event.user.speaker_profile.present?
end
end
def down
drop_table :events_speaker_profiles
end
end