Upgrade to Pro — share decks privately, control downloads, hide ads and more …

About using gem "cells" and "little refactoring"

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

About using gem "cells" and "little refactoring"

Avatar for Maxim Abramchuk

Maxim Abramchuk

March 15, 2015

Other Decks in Programming

Transcript

  1. Rails application • main functional - managing orders • complex

    business logic • many roles (admin, call operator, post manager, analyst and etc.)
  2. Rails application • main functional - managing orders • complex

    business logic • many roles (admin, call operator, post manager, analyst and etc.) • many order states (new, waiting for clarification, processing, sent, paid, returned)
  3. Some examples: • Post manager can’t see order’s contact information

    if order is in state ’New’. • Call operator should see ‘Process' button if order is in state 'Waiting clarification’ only. • Analyst should have a ‘Cancel’ button if order is in all the states, except ‘Sent’ and ‘Paid’.
  4. Problems: • Plenty of duplicated code, which we could not

    reuse • A lot of ‘IF’ statements in the views because of logic depending on order’s state
  5. Problems: • Plenty of duplicated code, which we could not

    reuse • A lot of ‘IF’ statements in the views because of logic depending on order’s state So, order’s logic was growing and our code was growing too.
  6. WE

  7. 1. Removed all the scoped controllers and created one OrdersController

    for all the roles 2. Created /concepts folder, and Order::Cell
  8. 1. Removed all the scoped controllers and created one OrdersController

    for all the roles 2. Created /concepts folder, and Order::Cell 3. in app/views/orders/index.slim