Skip to content

Instantly share code, notes, and snippets.

@nwjsmith
Created July 9, 2010 02:38
Embed
What would you like to do?
ruby-1.9.2-rc1 > f = Father.new
=> #<Father id: nil, name: nil, created_at: nil, updated_at: nil>
ruby-1.9.2-rc1 > f.name = "Dave"
=> "Dave"
ruby-1.9.2-rc1 > s = Son.new :name => "Nate"
=> #<Son id: nil, name: "Nate", father_id: nil, created_at: nil, updated_at: nil>
ruby-1.9.2-rc1 > f.son
f.son_ids f.sons f.sons= f.son_ids=
ruby-1.9.2-rc1 > f.sons << s
=> [#<Son id: nil, name: "Nate", father_id: nil, created_at: nil, updated_at: nil>]
ruby-1.9.2-rc1 > f.save!
=> true
ruby-1.9.2-rc1 > Son.all
=> [#<Son id: 1, name: "Nate", father_id: 1, created_at: "2010-07-09 02:36:21", updated_at: "2010-07-09 02:36:21">]
ruby-1.9.2-rc1 > stepfather = f.clone
=> #<Father id: nil, name: "Dave", created_at: "2010-07-09 02:36:21", updated_at: "2010-07-09 02:36:21">
ruby-1.9.2-rc1 > stepfather.sons << s
=> [#<Son id: 1, name: "Nate", father_id: 1, created_at: "2010-07-09 02:36:21", updated_at: "2010-07-09 02:36:21">, #<Son id: 1, name: "Nate", father_id: 1, created_at: "2010-07-09 02:36:21", updated_at: "2010-07-09 02:36:21">]
ruby-1.9.2-rc1 > stepfather.save!
=> true
ruby-1.9.2-rc1 > Son.all
=> [#<Son id: 1, name: "Nate", father_id: 1, created_at: "2010-07-09 02:36:21", updated_at: "2010-07-09 02:36:21">]
ruby-1.9.2-rc1 > stepfather.id
=> 2
ruby-1.9.2-rc1 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment