Skip to content

Instantly share code, notes, and snippets.

@semanticart
Created May 16, 2009 16:51
Show Gist options
  • Select an option

  • Save semanticart/112730 to your computer and use it in GitHub Desktop.

Select an option

Save semanticart/112730 to your computer and use it in GitHub Desktop.
>> project = Project.first
=> #<Project id: 1, name: "some project", created_at: "2009-05-16 16:37:41", updated_at: "2009-05-16 16:37:41">
>> project.tasks
=> []
>> project.tasks_attributes = [{:name => 'something'}]
=> [{:name=>"something"}]
>> project.save
=> true
>> project.tasks
=> [#<Task id: 3, name: "something", project_id: 1, deleted_at: nil, created_at: "2009-05-16 16:49:11", updated_at: "2009-05-16 16:49:11">]
>> project.tasks_attributes = [{:id => 3, '_delete' => '1'}]
=> [{"_delete"=>"1", :id=>3}]
>> project.save
=> true
>> project.reload
=> #<Project id: 1, name: "some project", created_at: "2009-05-16 16:37:41", updated_at: "2009-05-16 16:37:41">
>> project.tasks
=> []
>> Task.find(3)
ActiveRecord::RecordNotFound: Couldn't find Task with ID=3
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1591:in `find_one'
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1574:in `find_from_ids'
from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:616:in `find'
from (irb):13
from :0
>> Task.find_with_destroyed(3)
=> #<Task id: 3, name: "something", project_id: 1, deleted_at: "2009-05-16 16:49:29", created_at: "2009-05-16 16:49:11", updated_at: "2009-05-16 16:49:11">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment