Skip to content

Instantly share code, notes, and snippets.

@alexgriff
Created March 30, 2016 22:53
Show Gist options
  • Save alexgriff/5d7c0db6fc1f03efab1fb3a3e38371cf to your computer and use it in GitHub Desktop.
Save alexgriff/5d7c0db6fc1f03efab1fb3a3e38371cf to your computer and use it in GitHub Desktop.
class MakeVoterPolymorphic < ActiveRecord::Migration
def change
add_column :voters, :voterable_id, :integer
add_column :voters, :voterable_type, :string
end
end
# you could also use a shortened syntax that would do the same thing
# and add these two columns to the table
class MakeVoterPolymorphic < ActiveRecord::Migration
def change
change_table :voters do |t|
t.references :voterable, :polymorphic => true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment