Skip to content

Instantly share code, notes, and snippets.

@knowtheory
Created April 25, 2009 15:57
Show Gist options
  • Select an option

  • Save knowtheory/101671 to your computer and use it in GitHub Desktop.

Select an option

Save knowtheory/101671 to your computer and use it in GitHub Desktop.
>> @barney = Pet.first(:name => "Barney")
=> #<Pet id=2 name="Barney" kind="Scottish Terrier Dog">
>> @barney.toys
=> []
>> @barney.toys << Toy.get(1)
=> [#<Toy id=1 name="Chew Toy" price=nil>]
>> @barney.save
=> true
>> @barney.toys
=> [#<Toy id=1 name="Chew Toy" price=nil>]
>> Pet.first(:name => "Barney").toys
=> [#<Toy id=1 name="Chew Toy" price=nil>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment