-
-
Save rottingcorpse/5bb7725fbc81a38d6810 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[2] pry(main)> User.first.bid_listings.search('a') | |
User Load (1.2ms) SELECT "users".* FROM "users" LIMIT 1 | |
Listing Load (7.5ms) SELECT DISTINCT "listings".* FROM "listings" INNER JOIN "bids" ON "listings"."id" = "bids"."listing_id" WHERE "bids"."buyer_id" = 1 AND ((("listings"."brand" ILIKE '%a%' OR "listings"."model_name" ILIKE '%a%') OR "listings"."title" ILIKE '%a%')) ORDER BY created_at ASC | |
=> [#<Listing id: 31, shipping_methods: ["UPS", "FDX"], ship_to: "USA", ship_from: "00312", ship_weight: "5", ship_responsibility: "SELLER", retail_price: 43, classified_asking_price: 909, auction_opening_bid: 0, auction_reserve_price: 0, payment_methods: ["PERS", "PPAL"], description: "Lorem ipsum dolor sit amet, consectetuer adipiscing...", condition: 7, brand: "Dabvine", model_name: "pJKsbD5gc10KZ", title: "MIzQPn4NvIe", link_url: "http://www.example.com/", image_string: [{:url=>"http://pic6.audiogon.com/i/c/f/1302758059.jpg", :caption=>"Back middle"}], bold: false, hit_count: 37, category_id: 1, seller_id: 19, ending_at: "2012-09-05 13:49:25", auction: true, created_at: "2012-08-22 12:49:25", updated_at: "2012-08-24 12:50:03", status: 1, demo: false, current_price: 17000, featured: false, has_remote_control: false, has_original_box: false, has_owners_manual: false, staff_pick: false, other_shipper_rate: nil, buy_it_now_enabled: true, buy_it_now_only: false, length: 5, width: 2, height: 4, paid: false, media: false, media_format: nil, relisted: false, legacy_timestamp: nil, creation_id: nil, slug: "preamplifiers-dabvine-pjksbd5gc10kz-mizqpn4nvie-201...", suspended: false, geocoded_ship_from_id: nil, bids_count: 2, offers_count: 0, archived_at: nil, questions_count: 0, relisted_at: nil, relist_id: nil, exchanges_count: 0>] | |
[3] pry(main)> User.first.offer_listings.search('a') | |
User Load (0.8ms) SELECT "users".* FROM "users" LIMIT 1 | |
Listing Load (5.1ms) SELECT DISTINCT "listings".* FROM "listings" INNER JOIN "offers" ON "listings"."id" = "offers"."listing_id" WHERE "offers"."buyer_id" = 1 AND ((("listings"."brand" ILIKE '%a%' OR "listings"."model_name" ILIKE '%a%') OR "listings"."title" ILIKE '%a%')) | |
=> [#<Listing id: 32, shipping_methods: ["UPS", "FDX"], ship_to: "USA", ship_from: "18798", ship_weight: "8", ship_responsibility: "SELLER", retail_price: 776, classified_asking_price: 702, auction_opening_bid: 0, auction_reserve_price: 0, payment_methods: ["PERS", "PPAL"], description: "Lorem ipsum dolor sit amet, consectetuer adipiscing...", condition: 10, brand: "Topicshots", model_name: "AXy3qlv9CoZKe", title: "dMlOPfsPakdHV", link_url: "http://www.example.com/", image_string: [{:url=>"http://pic6.audiogon.com/i/c/f/1302758059.jpg", :caption=>"Back middle"}], bold: true, hit_count: 2, category_id: 1, seller_id: 19, ending_at: "2012-09-21 12:49:26", auction: false, created_at: "2012-08-22 12:49:26", updated_at: "2012-08-24 12:49:26", status: 1, demo: false, current_price: 702, featured: false, has_remote_control: false, has_original_box: false, has_owners_manual: false, staff_pick: false, other_shipper_rate: nil, buy_it_now_enabled: false, buy_it_now_only: false, length: 6, width: 4, height: 10, paid: false, media: false, media_format: nil, relisted: false, legacy_timestamp: nil, creation_id: nil, slug: "preamplifiers-topicshots-axy3qlv9cozke-dmlopfspakdh...", suspended: false, geocoded_ship_from_id: nil, bids_count: 0, offers_count: 2, archived_at: nil, questions_count: 0, relisted_at: nil, relist_id: nil, exchanges_count: 0>] | |
[4] pry(main)> buying_listings = (User.first.bid_listings + User.first.offer_listings) | |
User Load (1.0ms) SELECT "users".* FROM "users" LIMIT 1 | |
User Load (1.0ms) SELECT "users".* FROM "users" LIMIT 1 | |
Listing Load (3.7ms) SELECT DISTINCT "listings".* FROM "listings" INNER JOIN "bids" ON "listings"."id" = "bids"."listing_id" WHERE "bids"."buyer_id" = 1 ORDER BY created_at ASC | |
Listing Load (1.7ms) SELECT DISTINCT "listings".* FROM "listings" INNER JOIN "offers" ON "listings"."id" = "offers"."listing_id" WHERE "offers"."buyer_id" = 1 | |
=> [#<Listing id: 31, shipping_methods: ["UPS", "FDX"], ship_to: "USA", ship_from: "00312", ship_weight: "5", ship_responsibility: "SELLER", retail_price: 43, classified_asking_price: 909, auction_opening_bid: 0, auction_reserve_price: 0, payment_methods: ["PERS", "PPAL"], description: "Lorem ipsum dolor sit amet, consectetuer adipiscing...", condition: 7, brand: "Dabvine", model_name: "pJKsbD5gc10KZ", title: "MIzQPn4NvIe", link_url: "http://www.example.com/", image_string: [{:url=>"http://pic6.audiogon.com/i/c/f/1302758059.jpg", :caption=>"Back middle"}], bold: false, hit_count: 37, category_id: 1, seller_id: 19, ending_at: "2012-09-05 13:49:25", auction: true, created_at: "2012-08-22 12:49:25", updated_at: "2012-08-24 12:50:03", status: 1, demo: false, current_price: 17000, featured: false, has_remote_control: false, has_original_box: false, has_owners_manual: false, staff_pick: false, other_shipper_rate: nil, buy_it_now_enabled: true, buy_it_now_only: false, length: 5, width: 2, height: 4, paid: false, media: false, media_format: nil, relisted: false, legacy_timestamp: nil, creation_id: nil, slug: "preamplifiers-dabvine-pjksbd5gc10kz-mizqpn4nvie-201...", suspended: false, geocoded_ship_from_id: nil, bids_count: 2, offers_count: 0, archived_at: nil, questions_count: 0, relisted_at: nil, relist_id: nil, exchanges_count: 0>, | |
#<Listing id: 32, shipping_methods: ["UPS", "FDX"], ship_to: "USA", ship_from: "18798", ship_weight: "8", ship_responsibility: "SELLER", retail_price: 776, classified_asking_price: 702, auction_opening_bid: 0, auction_reserve_price: 0, payment_methods: ["PERS", "PPAL"], description: "Lorem ipsum dolor sit amet, consectetuer adipiscing...", condition: 10, brand: "Topicshots", model_name: "AXy3qlv9CoZKe", title: "dMlOPfsPakdHV", link_url: "http://www.example.com/", image_string: [{:url=>"http://pic6.audiogon.com/i/c/f/1302758059.jpg", :caption=>"Back middle"}], bold: true, hit_count: 2, category_id: 1, seller_id: 19, ending_at: "2012-09-21 12:49:26", auction: false, created_at: "2012-08-22 12:49:26", updated_at: "2012-08-24 12:49:26", status: 1, demo: false, current_price: 702, featured: false, has_remote_control: false, has_original_box: false, has_owners_manual: false, staff_pick: false, other_shipper_rate: nil, buy_it_now_enabled: false, buy_it_now_only: false, length: 6, width: 4, height: 10, paid: false, media: false, media_format: nil, relisted: false, legacy_timestamp: nil, creation_id: nil, slug: "preamplifiers-topicshots-axy3qlv9cozke-dmlopfspakdh...", suspended: false, geocoded_ship_from_id: nil, bids_count: 0, offers_count: 2, archived_at: nil, questions_count: 0, relisted_at: nil, relist_id: nil, exchanges_count: 0>] | |
[5] pry(main)> buying_listings.search('a') | |
NoMethodError: undefined method `search' for #<Array:0x00000005cc21a8> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment