Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JudeQuintana/bf58c3567e738998ea51 to your computer and use it in GitHub Desktop.
Save JudeQuintana/bf58c3567e738998ea51 to your computer and use it in GitHub Desktop.
class CreateBirds < ActiveRecord::Migration
def change
create_table :comments do |t|
t.string :location
t.belongs_to :birdable, polymorphic: true
t.timestamps
end
end
end
class Bag < ActiveRecord::Base
def put_a_bird_on(location)
birds.create(location: location)
end
end
class Bird < ActiveRecord::Base
belongs_to :birdable, polymorphic: true
end
bag = Bag.new
bag.put_a_bird_on("it")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment