Created
October 2, 2014 18:54
-
-
Save bobbywilson0/75c5e822077a684b9e0b to your computer and use it in GitHub Desktop.
Put a bird on it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bag < ActiveRecord::Base | |
def put_a_bird_on(location) | |
birds.create(location: location) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bird < ActiveRecord::Base | |
belongs_to :birdable, polymorphic: true | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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