Skip to content

Instantly share code, notes, and snippets.

@nwjsmith
Created July 9, 2010 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwjsmith/468960 to your computer and use it in GitHub Desktop.
Save nwjsmith/468960 to your computer and use it in GitHub Desktop.
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