Skip to content

Instantly share code, notes, and snippets.

@styliii
Last active August 29, 2015 13:55
Show Gist options
  • Save styliii/8736404 to your computer and use it in GitHub Desktop.
Save styliii/8736404 to your computer and use it in GitHub Desktop.
=> #<User id: 110, email: "[email protected]", crypted_password: "$2a$10$oWWIP/cyDCkdjSAuabsWd.4LmITNER2.snHZNs1n9c8R...", salt: "y85TW1tozJXwXqxWsU7L", created_at: "2014-01-29 22:59:07", updated_at: "2014-01-29 22:59:08", remember_me_token: nil, remember_me_token_expires_at: nil, reset_password_token: nil, reset_password_token_expires_at: nil, reset_password_email_sent_at: nil, last_login_at: "2014-01-29 23:32:53", last_logout_at: nil, last_activity_at: "2014-01-31 16:50:57", first_name: "jaimel", last_name: "gauda", phone_number: "3144948435", zendesk_user_id: "605708293", last_login_from_ip_address: "24.6.52.99", used_free_months: 0, agree_to_tos: true, lead_id: nil, conversion_token: "">
irb(main):005:0> user.invoices
[Shard: slave_0] Invoice Load (1.3ms) SELECT `invoices`.* FROM `invoices` WHERE `invoices`.`user_id` = 110
=> #<ActiveRecord::Associations::CollectionProxy [#<Invoice id: 105, order_id: 112, user_id: 110, foreign_key: "in_3Ov9pbVLvRGBRg", aasm_state: "shipped", created_at: "2014-01-29 23:00:02", updated_at: "2014-01-29 23:00:15", owd_ref_number: "11752369">]>
irb(main):006:0> user.order
NoMethodError: undefined method `order' for #<User:0x0000000883c5b8>
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/activemodel-4.0.1/lib/active_model/attribute_methods.rb:439:in `method_missing'
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/activerecord-4.0.1/lib/active_record/attribute_methods.rb:155:in `method_missing'
from (irb):6
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands/console.rb:90:in `start'
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands/console.rb:9:in `start'
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
irb(main):007:0> user.orders.last
[Shard: slave_0] Order Load (1.3ms) SELECT `orders`.* FROM `orders` WHERE `orders`.`user_id` = 110 ORDER BY `orders`.`id` DESC LIMIT 1
=> #<Order id: 112, user_id: 110, created_at: "2014-01-29 22:59:08", updated_at: "2014-01-29 22:59:57", is_active: true, payment_provider_id: 108, purchasable_id: 1, purchasable_type: "Plan", aasm_state: "processing", payment_provider_foreign_key: "sub_3Ov9hnrdKZiAKc", coupon_id: nil, payment_provider_foreign_key_type: "subscription", reference_number: "9ac67863f0">
irb(main):008:0> order = user.orders.last
[Shard: slave_0] Order Load (1.3ms) SELECT `orders`.* FROM `orders` WHERE `orders`.`user_id` = 110 ORDER BY `orders`.`id` DESC LIMIT 1
=> #<Order id: 112, user_id: 110, created_at: "2014-01-29 22:59:08", updated_at: "2014-01-29 22:59:57", is_active: true, payment_provider_id: 108, purchasable_id: 1, purchasable_type: "Plan", aasm_state: "processing", payment_provider_foreign_key: "sub_3Ov9hnrdKZiAKc", coupon_id: nil, payment_provider_foreign_key_type: "subscription", reference_number: "9ac67863f0">
irb(main):009:0> shipping_address = user.shipping_address
[Shard: slave_0] Address Load (1.3ms) SELECT `addresses`.* FROM `addresses` WHERE `addresses`.`user_id` = 110 AND `addresses`.`type_of` = 'shipping' ORDER BY `addresses`.`id` ASC LIMIT 1
=> #<Address id: 220, line1: "123 shipping", line2: "unit 3", city: "shipping", state: "CA", zip: "22222", country: nil, type_of: "shipping", user_id: 110, created_at: "2014-01-29 22:59:07", updated_at: "2014-01-29 22:59:07", ship_to: nil, name: "JAIMEL GAUDA">
irb(main):010:0> shipping_address = {
irb(main):011:1* address_1: shipping_address.line1.upcase,
irb(main):012:1* address_2: shipping_address.line2.try(:upcase),
irb(main):013:1* city: shipping_address.city.upcase,
irb(main):014:1* region: shipping_address.state.upcase,
irb(main):015:1* countrycode: "US",
irb(main):016:1* postcode: shipping_address.zip,
irb(main):017:1* }
=> {:address_1=>"123 SHIPPING", :address_2=>"UNIT 3", :city=>"SHIPPING", :region=>"CA", :countrycode=>"US", :postcode=>"22222"}
irb(main):018:0> response = @@owd_client.api.shipping_rate(:shipping_address => shipping_address,
irb(main):019:1* :items => [{:sku => order.current_sku, :qty => '1'}],
irb(main):020:1* :shipmethods => ['TANDATA_FEDEXFSMS.FEDEX.SP_PS'])
NameError: uninitialized class variable @@owd_client in Object
from (irb):18
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands/console.rb:90:in `start'
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands/console.rb:9:in `start'
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
irb(main):021:0> @@owd_client = OWD::Client.new(:client_id => Settings.owd.client_id, :client_authorization => Settings.owd.client_authorization)
=> #<OWD::Client:0x0000000822d050 @client_id=519, @client_authorization="8BE4/aCPkIWkfkJeZIcbHAM=", @testing="FALSE">
irb(main):022:0> response = @@owd_client.api.shipping_rate(:shipping_address => shipping_address,
irb(main):023:1* :items => [{:sku => order.current_sku, :qty => '1'}],
irb(main):024:1* :shipmethods => ['TANDATA_FEDEXFSMS.FEDEX.SP_PS'])
[Shard: slave_0] SubscriptionState Load (1.5ms) SELECT `subscription_states`.* FROM `subscription_states` WHERE `subscription_states`.`order_id` = 112 ORDER BY `subscription_states`.`id` ASC LIMIT 1
(0.8ms) BEGIN
(0.7ms) COMMIT
(0.6ms) BEGIN
(0.6ms) COMMIT
[Shard: slave_0] Plan Load (18.8ms) SELECT `plans`.* FROM `plans` WHERE `plans`.`id` = 1 ORDER BY `plans`.`id` ASC LIMIT 1
[Shard: slave_0] Product Load (1.0ms) SELECT `products`.* FROM `products` WHERE `products`.`id` = 2 ORDER BY `products`.`id` ASC LIMIT 1
=> {"OWD_SHIPPING_RATE_RESPONSE"=>{"ADDRESS"=>{"RESULT"=>"UNCORRECTED", "ADDRESS_1"=>"123 SHIPPING", "ADDRESS_2"=>"UNIT 3", "CITY"=>"SHIPPING", "REGION"=>"CA", "POSTCODE"=>"22222", "COUNTRYCODE"=>"US"}, "RATES"=>nil, "weight_lbs"=>"0.24"}, "results"=>"SUCCESS"}
irb(main):025:0> response["OWD_SHIPPING_RATE_RESPONSE"]["RATES"]["RATE"]["COST"].to_f
NoMethodError: undefined method `[]' for nil:NilClass
from (irb):25
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands/console.rb:90:in `start'
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands/console.rb:9:in `start'
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
irb(main):026:0> shipping_address
=> {:address_1=>"123 SHIPPING", :address_2=>"UNIT 3", :city=>"SHIPPING", :region=>"CA", :countrycode=>"US", :postcode=>"22222"}
irb(main):027:0> User.where(email: '[email protected]').first
[Shard: slave_0] User Load (3.1ms) SELECT `users`.* FROM `users` WHERE `users`.`email` = '[email protected]' ORDER BY `users`.`id` ASC LIMIT 1
=> #<User id: 78, email: "[email protected]", crypted_password: "$2a$10$Td.shKyXbLPEpzidBAhp3ewiK64eTNalZnQedQHAEl6c...", salt: "K4sN1oyYeZes83koG1G4", created_at: "2013-12-18 19:53:31", updated_at: "2014-01-21 07:50:15", remember_me_token: nil, remember_me_token_expires_at: nil, reset_password_token: "xoL8MF6VsC4P1VzzJKtH", reset_password_token_expires_at: nil, reset_password_email_sent_at: "2014-01-20 18:46:47", last_login_at: "2014-01-28 00:52:07", last_logout_at: "2014-01-28 23:36:25", last_activity_at: "2014-01-30 20:04:28", first_name: "Li", last_name: "Ouyang", phone_number: "(857)212-5555", zendesk_user_id: "571569606", last_login_from_ip_address: "24.6.52.99", used_free_months: 0, agree_to_tos: true, lead_id: 226, conversion_token: nil>
irb(main):028:0> user = _
=> #<User id: 78, email: "[email protected]", crypted_password: "$2a$10$Td.shKyXbLPEpzidBAhp3ewiK64eTNalZnQedQHAEl6c...", salt: "K4sN1oyYeZes83koG1G4", created_at: "2013-12-18 19:53:31", updated_at: "2014-01-21 07:50:15", remember_me_token: nil, remember_me_token_expires_at: nil, reset_password_token: "xoL8MF6VsC4P1VzzJKtH", reset_password_token_expires_at: nil, reset_password_email_sent_at: "2014-01-20 18:46:47", last_login_at: "2014-01-28 00:52:07", last_logout_at: "2014-01-28 23:36:25", last_activity_at: "2014-01-30 20:04:28", first_name: "Li", last_name: "Ouyang", phone_number: "(857)212-5555", zendesk_user_id: "571569606", last_login_from_ip_address: "24.6.52.99", used_free_months: 0, agree_to_tos: true, lead_id: 226, conversion_token: nil>
irb(main):029:0> user.shippigng_address
NoMethodError: undefined method `shippigng_address' for #<User:0x00000008bdd168>
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/activemodel-4.0.1/lib/active_model/attribute_methods.rb:439:in `method_missing'
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/activerecord-4.0.1/lib/active_record/attribute_methods.rb:155:in `method_missing'
from (irb):29
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands/console.rb:90:in `start'
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands/console.rb:9:in `start'
from /home/deploy/.bundler/bevel_commerce_goatee/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
irb(main):030:0> shipping_address = user.shipping_address
[Shard: slave_0] Address Load (1.6ms) SELECT `addresses`.* FROM `addresses` WHERE `addresses`.`user_id` = 78 AND `addresses`.`type_of` = 'shipping' ORDER BY `addresses`.`id` ASC LIMIT 1
=> #<Address id: 156, line1: "22 Irving Pl", line2: nil, city: "New York", state: "NY", zip: "10003", country: nil, type_of: "shipping", user_id: 78, created_at: "2013-12-18 19:53:31", updated_at: "2014-01-14 19:07:32", ship_to: "", name: "Li Ouyang">
irb(main):031:0> shipping_address = {
irb(main):032:1* address_1: shipping_address.line1.upcase,
irb(main):033:1* address_2: shipping_address.line2.try(:upcase),
irb(main):034:1* city: shipping_address.city.upcase,
irb(main):035:1* region: shipping_address.state.upcase,
irb(main):036:1* countrycode: "US",
irb(main):037:1* postcode: shipping_address.zip,
irb(main):038:1* }
=> {:address_1=>"22 IRVING PL", :address_2=>nil, :city=>"NEW YORK", :region=>"NY", :countrycode=>"US", :postcode=>"10003"}
irb(main):039:0>
irb(main):040:0* response = @@owd_client.api.shipping_rate(:shipping_address => shipping_address,
irb(main):041:1* :items => [{:sku => order.current_sku, :qty => '1'}],
irb(main):042:1* :shipmethods => ['TANDATA_FEDEXFSMS.FEDEX.SP_PS'])
(0.9ms) BEGIN
(0.6ms) COMMIT
(0.6ms) BEGIN
(0.6ms) COMMIT
=> {"OWD_SHIPPING_RATE_RESPONSE"=>{"ADDRESS"=>{"RESULT"=>"CORRECTED", "ADDRESS_1"=>"22 IRVING PL", "ADDRESS_2"=>nil, "CITY"=>"NEW YORK", "REGION"=>"NY", "POSTCODE"=>"10003-2304", "COUNTRYCODE"=>"US"}, "RATES"=>{"RATE"=>{"CODE"=>"TANDATA_FEDEXFSMS.FEDEX.SP_PS", "NAME"=>"FedEx SmartPost Parcel Select", "ERROR"=>" Invalid package weight"}}, "weight_lbs"=>"0.24"}, "results"=>"SUCCESS"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment