Sha256: 1f18a339a12558f73f221cde5c08c03d0499a6459c3dcdfebdb88b3e38cc37f9

Contents?: true

Size: 560 Bytes

Versions: 1

Compression:

Stored size: 560 Bytes

Contents

class RemoveOptionIdFromQuestions < ActiveRecord::Migration
  class Tasks::Taskables::Question < ActiveRecord::Base; end

  class Tasks::Taskables::Question::Answer < ActiveRecord::Base
    has_many :votes
    belongs_to :option
  end

  class Tasks::Taskables::Question::Vote < ActiveRecord::Base
    belongs_to :option
    belongs_to :answer
  end

  def up
    Tasks::Taskables::Question::Answer.all.each do |answer|
      answer.votes.create option: answer.option
    end

  	remove_column :tasks_taskables_question_answers, :option_id, :integer
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tasuku-0.0.1 db/migrate/20140512131526_remove_option_id_from_questions.rb