2016-10-05 14:55:34 +03:00
|
|
|
class TalkPreference < ActiveRecord::Base
|
|
|
|
self.primary_key = :unique_id
|
|
|
|
has_many :selected_talks
|
2024-09-13 19:13:40 +03:00
|
|
|
serialize :talks, type: Array
|
2016-10-05 14:55:34 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
class SelectedTalk < ApplicationRecord
|
|
|
|
belongs_to :talk_preference
|
|
|
|
end
|
|
|
|
|
|
|
|
class RemoveTalksFromTalkPreferences < ActiveRecord::Migration[5.0]
|
|
|
|
def up
|
|
|
|
remove_column :talk_preferences, :talks, :text
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
add_column :talk_preferences, :talks, :text
|
|
|
|
|
|
|
|
talk_preferences = TalkPreference.all
|
|
|
|
|
|
|
|
talk_preferences.each do |preference|
|
|
|
|
preference.talks = preference.selected_talks.pluck(:talk_id)
|
|
|
|
preference.save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|