Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. ruby-1.9.2-p0 :002 > User.where('settings.receive_newsletter' => true).map(&:name)
  2. => []
  3. ruby-1.9.2-p0 :003 > u = User.where(:email => /lewy/).first
  4. => #<User _id: 4e3110bdffd785027a000004, _type: nil, created_at: 2011-07-28 07:33:18 UTC, updated_at: 2011-07-28 07:33:18 UTC, deleted_at: nil, votes_stats: {}, name: "Paweł Lewiński", about: nil, place: nil, language: "pl", comment_counter: nil, registered_through: :facebook, slug: "pawel-lewinski", avatar_filename: nil, panel_last_company_id: nil, api_server_id: nil, campaign_ids: [], email: "lewy313@gmail.com", encrypted_password: "$2a$10$tG1mi9C8raqC.FjF0/ug.uQwkHFla50CXVKBUB8DFYjR0yHwBfYaG", authentication_token: nil, remember_token: "kgBLktoyYdUf40yyW7oi", remember_created_at: 2011-07-28 07:33:18 UTC, reset_password_token: nil, confirmation_token: nil, confirmed_at: 2011-07-28 07:33:18 UTC, confirmation_sent_at: nil, sign_in_count: 1, current_sign_in_at: 2011-07-28 07:33:18 UTC, last_sign_in_at: 2011-07-28 07:33:18 UTC, current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1">
  5. ruby-1.9.2-p0 :004 > u.settings.update_attributes(:receive_newsletter => true)
  6. => true
  7. ruby-1.9.2-p0 :005 > u.reload
  8. => #<User _id: 4e3110bdffd785027a000004, _type: nil, created_at: 2011-07-28 07:33:18 UTC, updated_at: 2011-07-28 07:33:18 UTC, deleted_at: nil, votes_stats: {}, name: "Paweł Lewiński", about: nil, place: nil, language: "pl", comment_counter: nil, registered_through: :facebook, slug: "pawel-lewinski", avatar_filename: nil, panel_last_company_id: nil, api_server_id: nil, campaign_ids: [], email: "lewy313@gmail.com", encrypted_password: "$2a$10$tG1mi9C8raqC.FjF0/ug.uQwkHFla50CXVKBUB8DFYjR0yHwBfYaG", authentication_token: nil, remember_token: "kgBLktoyYdUf40yyW7oi", remember_created_at: 2011-07-28 07:33:18 UTC, reset_password_token: nil, confirmation_token: nil, confirmed_at: 2011-07-28 07:33:18 UTC, confirmation_sent_at: nil, sign_in_count: 1, current_sign_in_at: 2011-07-28 07:33:18 UTC, last_sign_in_at: 2011-07-28 07:33:18 UTC, current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1">
  9. ruby-1.9.2-p0 :006 > u.settings.receive_newsletter
  10. => true
  11. ruby-1.9.2-p0 :007 > User.where('settings.receive_newsletter' => true).map(&:name)
  12. => []
  13. ruby-1.9.2-p0 :008 > User.where('settings.receive_newsletter' => true).count
  14. => 0
  15.  
  16. ruby-1.9.2-p0 :009 > u.settings.receive_newsletter
  17. => true
  18. ruby-1.9.2-p0 :010 > u.settings.receive_newsletter = true
  19. => true
  20. ruby-1.9.2-p0 :011 > u.settings.save
  21. => true
  22. ruby-1.9.2-p0 :012 > u.reload
  23. => #<User _id: 4e3110bdffd785027a000004, _type: nil, created_at: 2011-07-28 07:33:18 UTC, updated_at: 2011-07-28 07:33:18 UTC, deleted_at: nil, votes_stats: {}, name: "Paweł Lewiński", about: nil, place: nil, language: "pl", comment_counter: nil, registered_through: :facebook, slug: "pawel-lewinski", avatar_filename: nil, panel_last_company_id: nil, api_server_id: nil, campaign_ids: [], email: "lewy313@gmail.com", encrypted_password: "$2a$10$tG1mi9C8raqC.FjF0/ug.uQwkHFla50CXVKBUB8DFYjR0yHwBfYaG", authentication_token: nil, remember_token: "kgBLktoyYdUf40yyW7oi", remember_created_at: 2011-07-28 07:33:18 UTC, reset_password_token: nil, confirmation_token: nil, confirmed_at: 2011-07-28 07:33:18 UTC, confirmation_sent_at: nil, sign_in_count: 1, current_sign_in_at: 2011-07-28 07:33:18 UTC, last_sign_in_at: 2011-07-28 07:33:18 UTC, current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1">
  24. ruby-1.9.2-p0 :013 > User.where('settings.receive_newsletter' => true).count
  25. => 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement