2

weekly learning

Posted by ilake on August 13, 2016

“strive 8/7 ~ 8/13”

Use

  • [Gem] virtus

  • [Gem] sorcery

    1. authentication for Rails
  • [Gem] capybara-webkit

    1. A Capybara driver for headless WebKit to test JavaScript web apps
  • [Gem] capybara

    1. Acceptance test framework for web applications
  • [Gem] database_cleaner

    1. Strategies for cleaning databases
  • [Gem] temping

    1. model mockup, dynamic create db table for model test
  • [Gem] rubycritic

    1. provide a quality report of your Ruby code.
  • [Gem] CapistranoDeployTest

    1. Deploying a Rails App on Ubuntu 14.04 with Capistrano, Nginx, and Puma
  • [Gem] meta-tags

    1. make your Rails application SEO-friendly
  • [Gem] friendly_id

    1. for pretty url
  • [Gem] sitemap_generator

    1. create sitemap
  • [SEO] BROWSEO

    1. see how search engine read your website
  • [Gem] sphinx

    1. full-text search engine

Read

Book

  • JavaScript 語言核心

    • done (1), (2)
  • ios on rails

    • rails api design
  • Fearless Rails Refactoring

    • Refactoring recipes

      • Inline controller filters
        • extract filter to service
      • Explicitly render views with locals
        • pass the params to partials explicitly with render
      • Extract render/redirect methods
        • extract a private method for each render and redirect call
      • Extract a Single Action Controller class
        • extract like CreateProductsController only when ProductsController is too too too large
      • Extract routing constraint
        • use routing constraint to seperate controller action
      • Extract an adapter object
        • extract call external library to adapter object call
      • Extract a repository object
        • hide the direct ActiveRecord calls, isolated, add data storage on repo object
      • Extract a service object using the SimpleDelegator
        • move some domain or business logic to service object
      • Extract conditional validation into Service Object
        • when validation only used in one place, drop the condition on model, move it to service object
      • Extract a form object
        • move form to form object, more explicit and domain is expressed better
        • form object can’t have save method (SRP), Persistence is a seperate concern and different object should take care of it, form object only valid data
    • Patterns

      • Instantiating service objects *

      • The repository pattern *

      • Wrap external API with an adapter
        • isolated our interface from the implementation
      • 4 ways to early return from a rails controller

        • extracted_method; return if performed?
      • Service::Input *

      • Validations: Contexts *

      • Validations: Objectify *
    • Related topics

      • Service controller communication
        • True/false; return the object created/updated; return a response object that contains all the data and/or errors;
        • carry data through exceptions; controller passes callback methods;
      • Where to keep services
        • group your services according to the feature and then surround them with proper namespace
        • ex: Reporting::MonthlyReport, Forum::CreateNewTopic, TimeTracking::LogTimeService
      • Routing constraints
        • use routing constraints for situations where you need to choose differentctions based on some params
        • This makes the controller thinner and it’s more explicit what actios happening