Skip to content

Instantly share code, notes, and snippets.

@airy
Created November 2, 2010 06:45
Show Gist options
  • Save airy/659334 to your computer and use it in GitHub Desktop.
Save airy/659334 to your computer and use it in GitHub Desktop.
polymorphic migration
rails g migration Something attachable:polymorphic
or
rails g scaffold Something attachable:polymorphic
may can generate migration like this:
def self.up
create_table :somethings do |t|
t.references attachable, polymorphic => true
and model
class Something < ActiveRecord::Base
belongs_to :attachable, :polymorphic => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment