Skip to content

Instantly share code, notes, and snippets.

@naw
naw / event_sourcing_resources.md
Last active August 27, 2021 15:05
Event sourcing resources

For overall terminology for event-driven, even-sourcing, CQRS, etc. to help disambiguate by Martin Fowler:

At least a couple of videos by Greg Evans. He's given the same basic talks multiple times, so no need to watch every single variation, but here are a few distinct ones:

@naw
naw / has_many_through.rb
Created October 15, 2015 19:33
has_many_through nested_attributes setter vs collection setter
# This is not a bug report
#
# The purpose of this file is to illustrate
# differences in how Rails treats assignment
# to a nested_attributes setter vs. assignment
# to a collection directly.
#
# In the former, existing records are _not_ deleted if they are not present in the assigned data.
# In the latter, existing records _are_ deleted if they are not present in the assigned data.
@naw
naw / edge.rb
Created March 3, 2015 00:47
ThroughAssociation using same table twice (STI type and default_scope condition) problem
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@naw
naw / snippet.rb
Last active August 29, 2015 14:11
Capybara save_and_open_page after AJAX, before failed expectation
def original
click_link "Load something" # Runs AJAX
expect(page).to have_content('Something')
end
def bad
click_link "Load something" # Runs AJAX
save_and_open_page # to see why it isn't loading
expect(page).to have_content('Something')
end