Skip to content

Instantly share code, notes, and snippets.

@tamizhgeek
Created May 30, 2012 13:02
Show Gist options
  • Save tamizhgeek/2836178 to your computer and use it in GitHub Desktop.
Save tamizhgeek/2836178 to your computer and use it in GitHub Desktop.
ruby console
?> a = AAA.new()
=> #<AAA id: nil, parent_id: nil>
>> a.save!
=> true
>> b = AAA.new()
=> #<AAA id: nil, parent_id: nil>
>> b.save!
=> true
>> b.parent = a
=> #<AAA id: 1, parent_id: nil>
>> b.save!
=> true
>> a.destroy
=> #<AAA id: 1, parent_id: nil>
>> b
=> #<AAA id: 2, parent_id: 1>
>> b.parent_id = nil
=> nil
>> b.save!
=> true
>> b
=> #<AAA id: 2, parent_id: 1>
>> b.reload
=> #<AAA id: 2, parent_id: 1>
>>> b.parent = nil
=> nil
>> b.save!
=> true
>> b
=> #<AAA id: 2, parent_id: nil>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment