Pro Yearly is on sale from $80 to $50! »

How a small team built an e-commerce service w/ Ruby on Rails and Spree

How a small team built an e-commerce service w/ Ruby on Rails and Spree

Bf7ce9b68bbb0058721906b4db15b9b5?s=128

Kei Shiratsuchi

September 16, 2012
Tweet

Transcript

  1. How a small team built an e-commerce service w/ Ruby

    on Rails and Spree 4QSFFͰ໿ϲ݄Ͱ Πν͔Β&ίϚʔεαʔϏεΛ ࡞Δ·Ͱ Sapporo RubyKaigi 2012, 2012.09.16(Sun) ന౔ ܛ, Shiratsuchi Kei, @kei_s Slides in English, Talk in Japanese. Thank you for helping English. @yuki24 @tenderlove @morgan_randy
  2. @kei_s • ന౔ ܛ Shiratsuchi Kei • Born in Sapporo!!

    • Web app engineer • http://github.com/kei-s
  3. How a small team built an e-commerce service w/ Ruby

    on Rails and Spree 4QSFFͰ໿ϲ݄Ͱ Πν͔Β&ίϚʔεαʔϏεΛ ࡞Δ·Ͱ
  4. None
  5. OhMyGlasses http://www.ohmyglasses.jp

  6. http://www.facebook.com/ohmyglassesjp Coupon Code: sprk2012 !!! 12% OFF !!!

  7. None
  8. •Closed β in December 2011 •Public release in January 2012

    •Startup, 4 members+ •Seen on TV, twice OhMyGlasses
  9. •Built on E-Commerce framework w/ PHP, Magento. •No engineers. (Yes,

    I wasn’t there.) OhMyGlasses Closed β in December 2011
  10. http://www.flickr.com/photos/betsyweber/6719452305/

  11. http://www.flickr.com/photos/betsyweber/6719452305/ Get the first Feedback •“Are we able to sell

    glasses on the web?” •Many concerns. customers, products, operation ...
  12. None
  13. Answer a Tough Question Use Feedback to evaluate Run Iterations

    before the deadline
  14. •Go with PHP Framework •or, rewrite everything with Ruby on

    Rails When I joined, I make a hard decision ...
  15. None
  16. Spree E Commerce Platform Ruby On Rails 100% Open Source

  17. None
  18. None
  19. None
  20. Why Ruby/Rails? Why Spree?

  21. Why Ruby/Rails? •To run iterations faster, we need a familiar

    platform. •At least for me, it’s Ruby on Rails. •Why? I love coding in Ruby.
  22. Why Spree? •First time to develop an E-Commerce service. •We

    needed to build well structured cart/payment features.
  23. http://www.flickr.com/photos/ucumari/1985214623/

  24. Standing on the Shoulders of Giants http://www.flickr.com/photos/ucumari/1985214623/

  25. Spree’s structure Rails spree_core Ver 1.2.0 spree_api spree_dash spree_promo spree_auth_devise

    spree_cmd Ruby
  26. Rails spree_core spree_cmd Ruby spree_api spree_dash spree_promo spree_auth_devise Spree’s structure

    Ver 1.2.0
  27. spree_api spree_dash spree_promo spree_auth_devise Rails spree_core spree_cmd Ruby Kaminari Paperclip

    ActiveMerchant Devise Cancan RSpec FactoryGirl Spree’s structure Ver 1.2.0
  28. Spree’s Entity-Relationship Diagram

  29. User Product Cart Payment Promotion Tracking Shipment Spree’s Entity-Relationship Diagram

  30. http://www.flickr.com/photos/pasukaru76/4370098141/

  31. http://www.flickr.com/photos/pasukaru76/4370098141/ Inspect Giants

  32. •Only a little code descriptions are in the official documents.

    •So, I have to read code. Inspect Spree
  33. Inspect Code in RubyGems $ cd `bundle show spree_core` #=>

    /installed/gems/spree_core-1.2.0 $ vim app/models/spree/order.rb •Add debug code into gem code, check changes in the app.
  34. Inspect Code def gateway_action(source, action, success_state) protect_from_connection_error do check_environment response

    = payment_method.send(action, (amount * 100).round, source, gateway_options) handle_response(response, success_state, :failure) end end spree_core/app/models/payment/processing.rb
  35. spree_core/app/models/payment/processing.rb Inspect Code def gateway_action(source, action, success_state) protect_from_connection_error do check_environment

    response = payment_method.send(action, (amount * 100).round, source, gateway_options) handle_response(response, success_state, :failure) end end ? ?
  36. spree_core/app/models/payment/processing.rb Inspect Code with tapp def gateway_action(source, action, success_state) protect_from_connection_error

    do check_environment response = payment_method.send(action, (amount * 100).round, source.tapp, gateway_options) handle_response(response.tapp, success_state, :failure) end end Pretty-print object on console Pretty-print object on console https://github.com/esminc/tapp
  37. spree_core/app/models/payment/processing.rb Inspect Code with tapp def gateway_action(source, action, success_state) protect_from_connection_error

    do check_environment response = payment_method.send(action, (amount * 100).round, source.tapp, gateway_options) handle_response(response.tapp, success_state, :failure) end end #<Spree::CreditCard> #<ActiveMerchant::Billing::Response> https://github.com/esminc/tapp
  38. http://www.flickr.com/photos/bartelomeus/4184705426/

  39. http://www.flickr.com/photos/bartelomeus/4184705426/ Stay Focused

  40. •Develop features similar to the existing system.(exclude for operations) •No

    need to develop new features. (We can do after we ship it.) Focus & Ship
  41. One example

  42. Lens selection

  43. Lens selection Insert your own step in cart process Add

    lens price to total cost
  44. Insert your own step in cart process •Skip the detail

    :( •I implemented it at Spree Ver1.1.*. •You can do the same much easier with Ver1.2.0.
  45. Add lens price to total cost Order line_items 1 *

    adjustments 1 * Product A : Product B : 20000 JPY 23000 JPY Shipping : Coupon : Tax : Item total : 43000 JPY 500 JPY -3000 JPY (included) 0 JPY Total : 40500 JPY { {
  46. Add lens price to total cost Order line_items 1 *

    Product A : Product B : 20000 JPY 23000 JPY Shipping : Coupon : Tax : Lens : Item total : 43000 JPY 500 JPY -3000 JPY (included) 0 JPY 1500 JPY Total : 42000 JPY adjustments 1 * { { Lens adjustment
  47. •Write minimum code to achieve the goal. •Find out where

    to change. Focus
  48. And so ... •Began rewriting in January 2012 •Shipped the

    new version of the app at the end of March 2012
  49. How is Spree? building an EC web service? working for

    a Startup?
  50. Too Well structured cart/payment. Product part could be optional. Nice

    admin interface. How is Spree?
  51. •Fun to develop a B2C web service. •“Selling glasses with

    happiness is our goal”. Simple. How is building an EC web service?
  52. •I have a lot of things to do. •I can

    focus on what I really should do. •I have direct impact on the direction and results. How is working for a Startup?
  53. Repetition

  54. Answer a Tough Question Use Feedback to evaluate Run Iterations

    before the deadline
  55. Standing on the Shoulders of Giants http://www.flickr.com/photos/ucumari/1985214623/

  56. http://www.flickr.com/photos/pasukaru76/4370098141/ Inspect Giants

  57. http://www.flickr.com/photos/bartelomeus/4184705426/ Stay Focused

  58. And, We are hiring: Engineer, Designer Talk to @kei_s, @ikuma,

    @libkazz Thank you!