Skip to content

Instantly share code, notes, and snippets.

@wflanagan
Created March 19, 2012 00:22
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 wflanagan/2087011 to your computer and use it in GitHub Desktop.
Save wflanagan/2087011 to your computer and use it in GitHub Desktop.
1.9.2p290 :002 > b = _
=> #<Entity _id: 4f47260a93546d160b016fb4, _type: nil, created_at: 2012-02-24 05:54:18 UTC, updated_at: 2012-03-17 10:08:08 UTC, name: "petitjean gerald", twitter: "petitjeangerald", facebook: nil, found_at_url: nil, hashtags: {"tag"=>{"twitter"=>true}, "reachable_via"=>{"twitter"=>true}}, tags: ["twitter"], reachable_via: [], attribute_tags: [{"tag"=>"twitter"}, {"tag"=>"twitter"}], keywords: ["katsuni"], share_counts: {}, contact_info: {"facebook"=>[], "success"=>true, "created_at"=>2012-02-24 05:55:33 UTC, "tags"=>[], "twitter"=>[], "email"=>[], "phone"=>[], "linkedin"=>[], "google_plus"=>[], "youtube"=>[], "contact_form"=>false}, keyword_scores: {"katsuni"=>0.0}, wordsmaster_ids: [], directory_ids: [], forums: [], references: [], profiles_retrieved: true, profile_url: "http://a3.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", company: nil, title: nil, host_names: [], data: {"twitter_followers_count"=>2, "twitter_is_translator"=>2, "twitter_protected"=>false, "twitter_url"=>nil, "twitter_verified"=>false, "twitter_statuses_count"=>1, "twitter_listed_count"=>0, "twitter_geo_enabled"=>false, "twitter_friends_count"=>11, "twitter_created_at"=>"Sat Feb 18 16:40:20 +0000 2012", "twitter_contributors_enabled"=>false, "enriched_at"=>2012-02-24 05:55:37 UTC}, demographics: {}, geographics: {"language"=>"fr", "location"=>nil}, description: nil, new_profiles: [{"service"=>"twitter", "user_id"=>"petitjeangerald", "score"=>1.0}, {"service"=>"twitter", "username"=>"petitjeangerald", "score"=>1.0}], presence_score: 0, last_contact_info_update: 2012-02-24 05:55:37 UTC, last_share_counts_update: nil, ignore_project_ids: [], read_project_ids: []>
1.9.2p290 :003 > b._id
=> "4f47260a93546d160b016fb4"
1.9.2p290 :004 > z = _
=> "4f47260a93546d160b016fb4"
1.9.2p290 :005 > b["_id"] = BSON::ObjectId(z)
=> BSON::ObjectId('4f47260a93546d160b016fb4')
1.9.2p290 :006 > b.save
=> true
1.9.2p290 :007 > b
=> #<Entity _id: 4f47260a93546d160b016fb4, _type: nil, created_at: 2012-02-24 05:54:18 UTC, updated_at: 2012-03-19 00:20:24 UTC, name: "petitjean gerald", twitter: "petitjeangerald", facebook: nil, found_at_url: nil, hashtags: {"tag"=>{"twitter"=>true}, "reachable_via"=>{"twitter"=>true}}, tags: ["twitter"], reachable_via: [], attribute_tags: [{"tag"=>"twitter"}, {"tag"=>"twitter"}], keywords: ["katsuni"], share_counts: {}, contact_info: {"facebook"=>[], "success"=>true, "created_at"=>2012-02-24 05:55:33 UTC, "tags"=>[], "twitter"=>[], "email"=>[], "phone"=>[], "linkedin"=>[], "google_plus"=>[], "youtube"=>[], "contact_form"=>false}, keyword_scores: {"katsuni"=>0.0}, wordsmaster_ids: [], directory_ids: [], forums: [], references: [], profiles_retrieved: true, profile_url: "http://a3.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", company: nil, title: nil, host_names: [], data: {"twitter_followers_count"=>2, "twitter_is_translator"=>2, "twitter_protected"=>false, "twitter_url"=>nil, "twitter_verified"=>false, "twitter_statuses_count"=>1, "twitter_listed_count"=>0, "twitter_geo_enabled"=>false, "twitter_friends_count"=>11, "twitter_created_at"=>"Sat Feb 18 16:40:20 +0000 2012", "twitter_contributors_enabled"=>false, "enriched_at"=>2012-02-24 05:55:37 UTC}, demographics: {}, geographics: {"language"=>"fr", "location"=>nil}, description: nil, new_profiles: [{"service"=>"twitter", "user_id"=>"petitjeangerald", "score"=>1.0}, {"service"=>"twitter", "username"=>"petitjeangerald", "score"=>1.0}], presence_score: 0, last_contact_info_update: 2012-02-24 05:55:37 UTC, last_share_counts_update: nil, ignore_project_ids: [], read_project_ids: []>
1.9.2p290 :008 > Entity.find(z)
Mongoid::Errors::DocumentNotFound: Document not found for class Entity with id(s) 4f47260a93546d160b016fb4.
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/mongoid-2.2.6/lib/mongoid/criterion/inclusion.rb:252:in `block in execute_or_raise'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/mongoid-2.2.6/lib/mongoid/criterion/inclusion.rb:250:in `tap'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/mongoid-2.2.6/lib/mongoid/criterion/inclusion.rb:250:in `execute_or_raise'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/mongoid-2.2.6/lib/mongoid/criterion/inclusion.rb:106:in `find'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/mongoid-2.2.6/lib/mongoid/finders.rb:83:in `find'
from (irb):8
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/railties-3.0.11/lib/rails/commands/console.rb:44:in `start'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/railties-3.0.11/lib/rails/commands/console.rb:8:in `start'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/railties-3.0.11/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
1.9.2p290 :009 > b
=> #<Entity _id: 4f47260a93546d160b016fb4, _type: nil, created_at: 2012-02-24 05:54:18 UTC, updated_at: 2012-03-19 00:20:24 UTC, name: "petitjean gerald", twitter: "petitjeangerald", facebook: nil, found_at_url: nil, hashtags: {"tag"=>{"twitter"=>true}, "reachable_via"=>{"twitter"=>true}}, tags: ["twitter"], reachable_via: [], attribute_tags: [{"tag"=>"twitter"}, {"tag"=>"twitter"}], keywords: ["katsuni"], share_counts: {}, contact_info: {"facebook"=>[], "success"=>true, "created_at"=>2012-02-24 05:55:33 UTC, "tags"=>[], "twitter"=>[], "email"=>[], "phone"=>[], "linkedin"=>[], "google_plus"=>[], "youtube"=>[], "contact_form"=>false}, keyword_scores: {"katsuni"=>0.0}, wordsmaster_ids: [], directory_ids: [], forums: [], references: [], profiles_retrieved: true, profile_url: "http://a3.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", company: nil, title: nil, host_names: [], data: {"twitter_followers_count"=>2, "twitter_is_translator"=>2, "twitter_protected"=>false, "twitter_url"=>nil, "twitter_verified"=>false, "twitter_statuses_count"=>1, "twitter_listed_count"=>0, "twitter_geo_enabled"=>false, "twitter_friends_count"=>11, "twitter_created_at"=>"Sat Feb 18 16:40:20 +0000 2012", "twitter_contributors_enabled"=>false, "enriched_at"=>2012-02-24 05:55:37 UTC}, demographics: {}, geographics: {"language"=>"fr", "location"=>nil}, description: nil, new_profiles: [{"service"=>"twitter", "user_id"=>"petitjeangerald", "score"=>1.0}, {"service"=>"twitter", "username"=>"petitjeangerald", "score"=>1.0}], presence_score: 0, last_contact_info_update: 2012-02-24 05:55:37 UTC, last_share_counts_update: nil, ignore_project_ids: [], read_project_ids: []>
1.9.2p290 :010 > b.as_document
=> {"_id"=>BSON::ObjectId('4f47260a93546d160b016fb4'), "attribute_tags"=>[{"tag"=>"twitter"}, {"tag"=>"twitter"}], "contact_info"=>{"facebook"=>[], "success"=>true, "created_at"=>2012-02-24 05:55:33 UTC, "tags"=>[], "twitter"=>[], "email"=>[], "phone"=>[], "linkedin"=>[], "google_plus"=>[], "youtube"=>[], "contact_form"=>false}, "created_at"=>2012-02-24 05:54:18 UTC, "data"=>{"twitter_followers_count"=>2, "twitter_is_translator"=>2, "twitter_protected"=>false, "twitter_url"=>nil, "twitter_verified"=>false, "twitter_statuses_count"=>1, "twitter_listed_count"=>0, "twitter_geo_enabled"=>false, "twitter_friends_count"=>11, "twitter_created_at"=>"Sat Feb 18 16:40:20 +0000 2012", "twitter_contributors_enabled"=>false, "enriched_at"=>2012-02-24 05:55:37 UTC}, "demographics"=>{}, "description"=>nil, "directory_ids"=>[], "forums"=>[], "geographics"=>{"language"=>"fr", "location"=>nil}, "hashtags"=>{"tag"=>{"twitter"=>true}, "reachable_via"=>{"twitter"=>true}}, "host_names"=>[], "ignore_project_ids"=>[], "keyword_scores"=>{"katsuni"=>0.0}, "keywords"=>["katsuni"], "last_contact_info_update"=>2012-02-24 05:55:37 UTC, "name"=>"petitjean gerald", "new_profiles"=>[{"service"=>"twitter", "user_id"=>"petitjeangerald", "score"=>1.0}, {"service"=>"twitter", "username"=>"petitjeangerald", "score"=>1.0}], "presence_score"=>0, "profile_url"=>"http://a3.twimg.com/sticky/default_profile_images/default_profile_4_normal.png", "profiles_retrieved"=>true, "references"=>[], "share_counts"=>{}, "tags"=>["twitter"], "twitter"=>"petitjeangerald", "updated_at"=>2012-03-19 00:20:24 UTC, "wordsmaster_ids"=>[], "reachable_via"=>[], "read_project_ids"=>[]}
1.9.2p290 :011 > Entity.find(BSON::ObjectId(z))
Mongoid::Errors::DocumentNotFound: Document not found for class Entity with id(s) 4f47260a93546d160b016fb4.
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/mongoid-2.2.6/lib/mongoid/criterion/inclusion.rb:252:in `block in execute_or_raise'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/mongoid-2.2.6/lib/mongoid/criterion/inclusion.rb:250:in `tap'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/mongoid-2.2.6/lib/mongoid/criterion/inclusion.rb:250:in `execute_or_raise'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/mongoid-2.2.6/lib/mongoid/criterion/inclusion.rb:106:in `find'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/mongoid-2.2.6/lib/mongoid/finders.rb:83:in `find'
from (irb):11
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/railties-3.0.11/lib/rails/commands/console.rb:44:in `start'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/railties-3.0.11/lib/rails/commands/console.rb:8:in `start'
from /Users/wflanagan/.rvm/gems/ruby-1.9.2-p290@oma30/gems/railties-3.0.11/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment