Skip to content

Instantly share code, notes, and snippets.

View balakirevs's full-sized avatar

Aleksandr Balakiriev balakirevs

View GitHub Profile
class SidePostingActiveRecordOperationsProcessor < ActiveRecordOperationsProcessor
define_jsonapi_resources_callbacks :create_included_resource_operation
after_create_resource_operation :append_create_sideposted_to_one_resource_operations
before_create_resource_operation :append_create_sideposted_to_many_resources_operations
before_replace_fields_operation :append_create_sideposted_to_many_resources_operations
def append_create_sideposted_to_one_resource_operations
return if @result.is_a?(JSONAPI::ErrorsOperationResult)
@operations.each do |operation|
resource_klass = operation.resource_klass
@balakirevs
balakirevs / System Design.md
Created February 14, 2020 11:52 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@balakirevs
balakirevs / dirty_associations.rb
Created December 15, 2019 13:17 — forked from fadhlirahim/dirty_associations.rb
Awesome simple solution for Rails ActiveRecord dirty tracking associations
# Credit Brandon Weiss of http://anti-pattern.com/dirty-associations-with-activerecord
# app/models/dirty_associations.rb
module DirtyAssociations
attr_accessor :dirty
attr_accessor :_record_changes
def make_dirty(record)
self.dirty = true
self._record_changes = record