Skip to content

Instantly share code, notes, and snippets.

@bobbywilson0
Created October 2, 2014 18:54

Revisions

  1. bobbywilson0 created this gist Oct 2, 2014.
    10 changes: 10 additions & 0 deletions 20141002020853_create_birds.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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
    6 changes: 6 additions & 0 deletions bag.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    class Bag < ActiveRecord::Base

    def put_a_bird_on(location)
    birds.create(location: location)
    end
    end
    3 changes: 3 additions & 0 deletions bird.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    class Bird < ActiveRecord::Base
    belongs_to :birdable, polymorphic: true
    end
    2 changes: 2 additions & 0 deletions usage.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    bag = Bag.new
    bag.put_a_bird_on("it")