Forked from bobbywilson0/20141002020853_create_birds.rb
Last active
August 29, 2015 14:07
-
-
Save JudeQuintana/bf58c3567e738998ea51 to your computer and use it in GitHub Desktop.
This file contains 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 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 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 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