├── Procfile ├── README.md ├── admin ├── .gitignore ├── Gemfile ├── Gemfile.lock ├── Procfile ├── README.rdoc ├── Rakefile ├── app │ ├── assets │ │ ├── images │ │ │ └── .keep │ │ └── stylesheets │ │ │ ├── application.css │ │ │ └── scaffold.css │ ├── controllers │ │ ├── application_controller.rb │ │ ├── concerns │ │ │ └── .keep │ │ └── posts_controller.rb │ ├── helpers │ │ └── application_helper.rb │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── blog.rb │ │ ├── blog │ │ │ └── post.rb │ │ └── concerns │ │ │ └── .keep │ ├── services │ │ └── publisher.rb │ ├── views │ │ ├── layouts │ │ │ └── application.html.erb │ │ └── posts │ │ │ ├── index.html.erb │ │ │ └── show.html.erb │ └── workers │ │ └── blog │ │ └── posts_worker.rb ├── bin │ ├── bundle │ ├── rails │ ├── rake │ └── spring ├── config.ru ├── config │ ├── application.rb │ ├── boot.rb │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ ├── development.rb │ │ ├── production.rb │ │ └── test.rb │ ├── initializers │ │ ├── backtrace_silencers.rb │ │ ├── cookies_serializer.rb │ │ ├── filter_parameter_logging.rb │ │ ├── inflections.rb │ │ ├── mime_types.rb │ │ ├── session_store.rb │ │ ├── sneakers.rb │ │ └── wrap_parameters.rb │ ├── locales │ │ └── en.yml │ ├── routes.rb │ └── secrets.yml ├── db │ ├── migrate │ │ └── 20140518000244_create_blog_posts.rb │ ├── schema.rb │ └── seeds.rb ├── lib │ ├── assets │ │ └── .keep │ └── tasks │ │ └── .keep ├── log │ └── .keep ├── public │ ├── 404.html │ ├── 422.html │ ├── 500.html │ ├── favicon.ico │ └── robots.txt └── vendor │ └── assets │ └── stylesheets │ └── .keep ├── bin └── run ├── blog ├── .gitignore ├── Gemfile ├── Gemfile.lock ├── Procfile ├── README.rdoc ├── Rakefile ├── app │ ├── assets │ │ ├── images │ │ │ └── .keep │ │ └── stylesheets │ │ │ ├── application.css │ │ │ └── scaffold.css │ ├── controllers │ │ ├── application_controller.rb │ │ ├── concerns │ │ │ └── .keep │ │ └── posts_controller.rb │ ├── helpers │ │ └── application_helper.rb │ ├── mailers │ │ └── .keep │ ├── models │ │ ├── .keep │ │ ├── concerns │ │ │ └── .keep │ │ └── post.rb │ ├── services │ │ └── publisher.rb │ └── views │ │ ├── layouts │ │ └── application.html.erb │ │ └── posts │ │ ├── _form.html.erb │ │ ├── edit.html.erb │ │ ├── index.html.erb │ │ ├── new.html.erb │ │ └── show.html.erb ├── bin │ ├── bundle │ ├── rails │ ├── rake │ └── spring ├── config.ru ├── config │ ├── application.rb │ ├── boot.rb │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ ├── development.rb │ │ ├── production.rb │ │ └── test.rb │ ├── initializers │ │ ├── backtrace_silencers.rb │ │ ├── cookies_serializer.rb │ │ ├── filter_parameter_logging.rb │ │ ├── inflections.rb │ │ ├── mime_types.rb │ │ ├── session_store.rb │ │ └── wrap_parameters.rb │ ├── locales │ │ └── en.yml │ ├── routes.rb │ └── secrets.yml ├── db │ ├── migrate │ │ └── 20140517222119_create_posts.rb │ ├── schema.rb │ └── seeds.rb ├── lib │ ├── assets │ │ └── .keep │ └── tasks │ │ └── .keep ├── log │ └── .keep ├── public │ ├── 404.html │ ├── 422.html │ ├── 500.html │ ├── favicon.ico │ └── robots.txt └── vendor │ └── assets │ └── stylesheets │ └── .keep ├── config ├── Gemfile ├── Gemfile.lock └── Rakefile └── dashboard ├── .gitignore ├── Gemfile ├── Gemfile.lock ├── Procfile ├── README.rdoc ├── Rakefile ├── app ├── assets │ ├── images │ │ └── .keep │ └── stylesheets │ │ ├── application.css │ │ └── scaffold.css ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ └── home_controller.rb ├── helpers │ └── application_helper.rb ├── mailers │ └── .keep ├── models │ ├── .keep │ └── concerns │ │ └── .keep ├── services │ ├── page_views.rb │ └── recent_posts.rb ├── views │ ├── home │ │ └── index.html.erb │ └── layouts │ │ └── application.html.erb └── workers │ ├── page_views_worker.rb │ └── posts_worker.rb ├── bin ├── bundle ├── rails ├── rake └── spring ├── config.ru ├── config ├── application.rb ├── boot.rb ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── backtrace_silencers.rb │ ├── cookies_serializer.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── redis.rb │ ├── session_store.rb │ ├── sneakers.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── routes.rb └── secrets.yml ├── db └── seeds.rb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico └── robots.txt └── vendor └── assets └── stylesheets └── .keep /Procfile: -------------------------------------------------------------------------------- 1 | blog: foreman start -f blog/Procfile 2 | dash: foreman start -f dashboard/Procfile 3 | admin: foreman start -f admin/Procfile 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### RabbitMQ Event Sourcing Example 2 | 3 | ![](https://dl.dropboxusercontent.com/s/6vqm0w07skh906s/2014-05-18%20at%2003.27.png) 4 | 5 | ## Running the example 6 | 7 | ##### 1. Ensure RabbitMQ is installed and running 8 | 9 | On Mac OSX with homebrew you can install RabbitMQ with 10 | 11 | ```bash 12 | $ brew install rabbitmq 13 | ``` 14 | 15 | And start it using 16 | ``` 17 | $ /usr/local/opt/rabbitmq/sbin/rabbitmq-server 18 | ``` 19 | 20 | ##### 2. Setup and start all processes 21 | 22 | ```bash 23 | $ bin/run 24 | ``` 25 | 26 | ##### 3. Open all three applications in browser 27 | 28 | - [Blog (http://localhost:5001)](http://localhost:5001) 29 | - [Dashboard (http://localhost:5002)](http://localhost:5002) 30 | - [Admin (http://localhost:5003)](http://localhost:5003) 31 | -------------------------------------------------------------------------------- /admin/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/*.log 16 | /tmp 17 | -------------------------------------------------------------------------------- /admin/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rails', '4.1.1' 4 | gem 'sqlite3' 5 | 6 | gem 'sneakers', "0.1.1.pre" # 0.0.7 does not support namespaced workers 7 | 8 | gem 'spring', group: :development 9 | -------------------------------------------------------------------------------- /admin/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (4.1.1) 5 | actionpack (= 4.1.1) 6 | actionview (= 4.1.1) 7 | mail (~> 2.5.4) 8 | actionpack (4.1.1) 9 | actionview (= 4.1.1) 10 | activesupport (= 4.1.1) 11 | rack (~> 1.5.2) 12 | rack-test (~> 0.6.2) 13 | actionview (4.1.1) 14 | activesupport (= 4.1.1) 15 | builder (~> 3.1) 16 | erubis (~> 2.7.0) 17 | activemodel (4.1.1) 18 | activesupport (= 4.1.1) 19 | builder (~> 3.1) 20 | activerecord (4.1.1) 21 | activemodel (= 4.1.1) 22 | activesupport (= 4.1.1) 23 | arel (~> 5.0.0) 24 | activesupport (4.1.1) 25 | i18n (~> 0.6, >= 0.6.9) 26 | json (~> 1.7, >= 1.7.7) 27 | minitest (~> 5.1) 28 | thread_safe (~> 0.1) 29 | tzinfo (~> 1.1) 30 | amq-protocol (1.9.2) 31 | arel (5.0.1.20140414130214) 32 | builder (3.2.2) 33 | bunny (1.1.9) 34 | amq-protocol (>= 1.9.2) 35 | erubis (2.7.0) 36 | hike (1.2.3) 37 | i18n (0.6.9) 38 | json (1.8.1) 39 | mail (2.5.4) 40 | mime-types (~> 1.16) 41 | treetop (~> 1.4.8) 42 | mime-types (1.25.1) 43 | minitest (5.3.4) 44 | multi_json (1.10.0) 45 | polyglot (0.3.4) 46 | rack (1.5.2) 47 | rack-test (0.6.2) 48 | rack (>= 1.0) 49 | rails (4.1.1) 50 | actionmailer (= 4.1.1) 51 | actionpack (= 4.1.1) 52 | actionview (= 4.1.1) 53 | activemodel (= 4.1.1) 54 | activerecord (= 4.1.1) 55 | activesupport (= 4.1.1) 56 | bundler (>= 1.3.0, < 2.0) 57 | railties (= 4.1.1) 58 | sprockets-rails (~> 2.0) 59 | railties (4.1.1) 60 | actionpack (= 4.1.1) 61 | activesupport (= 4.1.1) 62 | rake (>= 0.8.7) 63 | thor (>= 0.18.1, < 2.0) 64 | rake (10.3.2) 65 | serverengine (1.5.7) 66 | sigdump (~> 0.2.2) 67 | sigdump (0.2.2) 68 | sneakers (0.1.1.pre) 69 | bunny (~> 1.1.3) 70 | serverengine 71 | thor 72 | thread 73 | spring (1.1.3) 74 | sprockets (2.12.1) 75 | hike (~> 1.2) 76 | multi_json (~> 1.0) 77 | rack (~> 1.0) 78 | tilt (~> 1.1, != 1.3.0) 79 | sprockets-rails (2.1.3) 80 | actionpack (>= 3.0) 81 | activesupport (>= 3.0) 82 | sprockets (~> 2.8) 83 | sqlite3 (1.3.9) 84 | thor (0.19.1) 85 | thread (0.1.4) 86 | thread_safe (0.3.3) 87 | tilt (1.4.1) 88 | treetop (1.4.15) 89 | polyglot 90 | polyglot (>= 0.3.1) 91 | tzinfo (1.1.0) 92 | thread_safe (~> 0.1) 93 | 94 | PLATFORMS 95 | ruby 96 | 97 | DEPENDENCIES 98 | rails (= 4.1.1) 99 | sneakers (= 0.1.1.pre) 100 | spring 101 | sqlite3 102 | -------------------------------------------------------------------------------- /admin/Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec rails s -p 5003 2 | worker: env WORKERS=Blog::PostsWorker bundle exec rake sneakers:run 3 | -------------------------------------------------------------------------------- /admin/README.rdoc: -------------------------------------------------------------------------------- 1 | == README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | 26 | 27 | Please feel free to use a different markup language if you do not plan to run 28 | rake doc:app. 29 | -------------------------------------------------------------------------------- /admin/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | require 'sneakers/tasks' 6 | 7 | Rails.application.load_tasks 8 | -------------------------------------------------------------------------------- /admin/app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/admin/app/assets/images/.keep -------------------------------------------------------------------------------- /admin/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /admin/app/assets/stylesheets/scaffold.css: -------------------------------------------------------------------------------- 1 | body { background-color: #fff; color: #333; } 2 | 3 | body, p, ol, ul, td { 4 | font-family: verdana, arial, helvetica, sans-serif; 5 | font-size: 13px; 6 | line-height: 18px; 7 | } 8 | 9 | pre { 10 | background-color: #eee; 11 | padding: 10px; 12 | font-size: 11px; 13 | } 14 | 15 | a { color: #000; } 16 | a:visited { color: #666; } 17 | a:hover { color: #fff; background-color:#000; } 18 | 19 | div.field, div.actions { 20 | margin-bottom: 10px; 21 | } 22 | 23 | #notice { 24 | color: green; 25 | } 26 | 27 | .field_with_errors { 28 | padding: 2px; 29 | background-color: red; 30 | display: table; 31 | } 32 | 33 | #error_explanation { 34 | width: 450px; 35 | border: 2px solid red; 36 | padding: 7px; 37 | padding-bottom: 0; 38 | margin-bottom: 20px; 39 | background-color: #f0f0f0; 40 | } 41 | 42 | #error_explanation h2 { 43 | text-align: left; 44 | font-weight: bold; 45 | padding: 5px 5px 5px 15px; 46 | font-size: 12px; 47 | margin: -7px; 48 | margin-bottom: 0px; 49 | background-color: #c00; 50 | color: #fff; 51 | } 52 | 53 | #error_explanation ul li { 54 | font-size: 12px; 55 | list-style: square; 56 | } 57 | -------------------------------------------------------------------------------- /admin/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | 6 | before_action :publish_page_view 7 | 8 | protected 9 | 10 | def publish_page_view 11 | Publisher.publish("page_views", 12 | site: "admin", 13 | path: request.path, 14 | method: request.method 15 | ) 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /admin/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/admin/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /admin/app/controllers/posts_controller.rb: -------------------------------------------------------------------------------- 1 | class PostsController < ApplicationController 2 | def index 3 | @posts = Blog::Post.all 4 | end 5 | 6 | def show 7 | @post = Blog::Post.find(params[:id]) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /admin/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /admin/app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/admin/app/mailers/.keep -------------------------------------------------------------------------------- /admin/app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/admin/app/models/.keep -------------------------------------------------------------------------------- /admin/app/models/blog.rb: -------------------------------------------------------------------------------- 1 | module Blog 2 | def self.table_name_prefix 3 | 'blog_' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /admin/app/models/blog/post.rb: -------------------------------------------------------------------------------- 1 | class Blog::Post < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /admin/app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/admin/app/models/concerns/.keep -------------------------------------------------------------------------------- /admin/app/services/publisher.rb: -------------------------------------------------------------------------------- 1 | class Publisher 2 | def self.publish(exchange, message = {}) 3 | x = channel.fanout("admin.#{exchange}") 4 | x.publish(message.to_json) 5 | end 6 | 7 | def self.channel 8 | @channel ||= connection.create_channel 9 | end 10 | 11 | def self.connection 12 | @connection ||= Bunny.new.tap do |c| 13 | c.start 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /admin/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Admin 5 | <%= stylesheet_link_tag 'application', media: 'all' %> 6 | <%= csrf_meta_tags %> 7 | 8 | 9 |

Admin

10 | <%= yield %> 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /admin/app/views/posts/index.html.erb: -------------------------------------------------------------------------------- 1 |

Listing posts

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | <% @posts.each do |post| %> 13 | 14 | 15 | 16 | 17 | <% end %> 18 | 19 |
Title
<%= post.title %><%= link_to 'Show', post_path(post) %>
20 | -------------------------------------------------------------------------------- /admin/app/views/posts/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

4 | Title: 5 | <%= @post.title %> 6 |

7 | 8 | <%= link_to 'Back', posts_path %> 9 | -------------------------------------------------------------------------------- /admin/app/workers/blog/posts_worker.rb: -------------------------------------------------------------------------------- 1 | module Blog 2 | class PostsWorker 3 | include Sneakers::Worker 4 | from_queue "admin.posts", env: nil 5 | 6 | def work(raw_post) 7 | params = JSON.parse(raw_post) 8 | 9 | Blog::Post.where(id: params["id"]).first_or_initialize.tap do |post| 10 | post.title = params["title"] 11 | post.save! 12 | end 13 | 14 | ack! 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /admin/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /admin/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /admin/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /admin/bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast 4 | # It gets overwritten when you run the `spring binstub` command 5 | 6 | unless defined?(Spring) 7 | require "rubygems" 8 | require "bundler" 9 | 10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) 11 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) 12 | ENV["GEM_HOME"] = "" 13 | Gem.paths = ENV 14 | 15 | gem "spring", match[1] 16 | require "spring/binstub" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /admin/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /admin/config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | # Pick the frameworks you want: 4 | require "active_model/railtie" 5 | require "active_record/railtie" 6 | require "action_controller/railtie" 7 | require "action_mailer/railtie" 8 | require "action_view/railtie" 9 | require "sprockets/railtie" 10 | # require "rails/test_unit/railtie" 11 | 12 | # Require the gems listed in Gemfile, including any gems 13 | # you've limited to :test, :development, or :production. 14 | Bundler.require(*Rails.groups) 15 | 16 | module Admin 17 | class Application < Rails::Application 18 | # Settings in config/environments/* take precedence over those specified here. 19 | # Application configuration should go into files in config/initializers 20 | # -- all .rb files in that directory are automatically loaded. 21 | 22 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 23 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 24 | # config.time_zone = 'Central Time (US & Canada)' 25 | 26 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 27 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 28 | # config.i18n.default_locale = :de 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /admin/config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | 4 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) 5 | -------------------------------------------------------------------------------- /admin/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /admin/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /admin/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations. 23 | config.active_record.migration_error = :page_load 24 | 25 | # Debug mode disables concatenation and preprocessing of assets. 26 | # This option may cause significant delays in view rendering with a large 27 | # number of complex assets. 28 | config.assets.debug = true 29 | 30 | # Adds additional error checking when serving assets at runtime. 31 | # Checks for improperly declared sprockets dependencies. 32 | # Raises helpful error messages. 33 | config.assets.raise_runtime_errors = true 34 | 35 | # Raises error for missing translations 36 | # config.action_view.raise_on_missing_translations = true 37 | end 38 | -------------------------------------------------------------------------------- /admin/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. 20 | # config.action_dispatch.rack_cache = true 21 | 22 | # Disable Rails's static asset server (Apache or nginx will already do this). 23 | config.serve_static_assets = false 24 | 25 | # Compress JavaScripts and CSS. 26 | config.assets.js_compressor = :uglifier 27 | # config.assets.css_compressor = :sass 28 | 29 | # Do not fallback to assets pipeline if a precompiled asset is missed. 30 | config.assets.compile = false 31 | 32 | # Generate digests for assets URLs. 33 | config.assets.digest = true 34 | 35 | # Version of your assets, change this if you want to expire all your assets. 36 | config.assets.version = '1.0' 37 | 38 | # Specifies the header that your server uses for sending files. 39 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 41 | 42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 43 | # config.force_ssl = true 44 | 45 | # Set to :debug to see everything in the log. 46 | config.log_level = :info 47 | 48 | # Prepend all log lines with the following tags. 49 | # config.log_tags = [ :subdomain, :uuid ] 50 | 51 | # Use a different logger for distributed setups. 52 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 53 | 54 | # Use a different cache store in production. 55 | # config.cache_store = :mem_cache_store 56 | 57 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 58 | # config.action_controller.asset_host = "http://assets.example.com" 59 | 60 | # Precompile additional assets. 61 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 62 | # config.assets.precompile += %w( search.js ) 63 | 64 | # Ignore bad email addresses and do not raise email delivery errors. 65 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 66 | # config.action_mailer.raise_delivery_errors = false 67 | 68 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 69 | # the I18n.default_locale when a translation cannot be found). 70 | config.i18n.fallbacks = true 71 | 72 | # Send deprecation notices to registered listeners. 73 | config.active_support.deprecation = :notify 74 | 75 | # Disable automatic flushing of the log to improve performance. 76 | # config.autoflush_log = false 77 | 78 | # Use default logging formatter so that PID and timestamp are not suppressed. 79 | config.log_formatter = ::Logger::Formatter.new 80 | 81 | # Do not dump schema after migrations. 82 | config.active_record.dump_schema_after_migration = false 83 | end 84 | -------------------------------------------------------------------------------- /admin/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static asset server for tests with Cache-Control for performance. 16 | config.serve_static_assets = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | 37 | # Raises error for missing translations 38 | # config.action_view.raise_on_missing_translations = true 39 | end 40 | -------------------------------------------------------------------------------- /admin/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /admin/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json -------------------------------------------------------------------------------- /admin/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /admin/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /admin/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /admin/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_admin_session' 4 | -------------------------------------------------------------------------------- /admin/config/initializers/sneakers.rb: -------------------------------------------------------------------------------- 1 | Sneakers.configure({}) 2 | Sneakers.logger.level = Logger::INFO 3 | -------------------------------------------------------------------------------- /admin/config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /admin/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /admin/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | resources :posts, only: [:index, :show] 3 | 4 | root to: "posts#index" 5 | end 6 | -------------------------------------------------------------------------------- /admin/config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: fd3d464e538de0dd08f801559e04072c9da672c29fbb6576ca0ce8663cbcd1c57da21645eec4246f793f0927c9d18946294584f4ced5718c8425ac2649e20d6d 15 | 16 | test: 17 | secret_key_base: ad5f069a9fbc6bf478a7a191b5d2914d25c1cc4fb1080dceac6b9ffad79cb8f485648af024c6adc7e9f6205ca0c7b7ae79d0b1a0efeddeb00afec78f1afa6e3a 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /admin/db/migrate/20140518000244_create_blog_posts.rb: -------------------------------------------------------------------------------- 1 | class CreateBlogPosts < ActiveRecord::Migration 2 | def change 3 | create_table :blog_posts do |t| 4 | t.string :title 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /admin/db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended that you check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(version: 20140518000244) do 15 | 16 | create_table "blog_posts", force: true do |t| 17 | t.string "title" 18 | t.datetime "created_at" 19 | t.datetime "updated_at" 20 | end 21 | 22 | end 23 | -------------------------------------------------------------------------------- /admin/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /admin/lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/admin/lib/assets/.keep -------------------------------------------------------------------------------- /admin/lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/admin/lib/tasks/.keep -------------------------------------------------------------------------------- /admin/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/admin/log/.keep -------------------------------------------------------------------------------- /admin/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /admin/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /admin/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /admin/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/admin/public/favicon.ico -------------------------------------------------------------------------------- /admin/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /admin/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/admin/vendor/assets/stylesheets/.keep -------------------------------------------------------------------------------- /bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -x 5 | 6 | cd blog 7 | hash -r 8 | bundle check || bundle install 9 | bundle exec rake db:migrate 10 | cd .. 11 | 12 | cd dashboard 13 | hash -r 14 | bundle check || bundle install 15 | cd .. 16 | 17 | cd admin 18 | hash -r 19 | bundle check || bundle install 20 | bundle exec rake db:migrate 21 | cd .. 22 | 23 | cd config 24 | hash -r 25 | bundle check || bundle install 26 | bundle exec rake rabbitmq:setup 27 | cd .. 28 | 29 | which foreman > /dev/null 2>&1 || gem install foreman 30 | foreman start 31 | -------------------------------------------------------------------------------- /blog/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/*.log 16 | /tmp 17 | -------------------------------------------------------------------------------- /blog/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rails', '4.1.1' 4 | gem 'sqlite3' 5 | 6 | gem 'bunny' 7 | 8 | gem 'spring', group: :development 9 | -------------------------------------------------------------------------------- /blog/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (4.1.1) 5 | actionpack (= 4.1.1) 6 | actionview (= 4.1.1) 7 | mail (~> 2.5.4) 8 | actionpack (4.1.1) 9 | actionview (= 4.1.1) 10 | activesupport (= 4.1.1) 11 | rack (~> 1.5.2) 12 | rack-test (~> 0.6.2) 13 | actionview (4.1.1) 14 | activesupport (= 4.1.1) 15 | builder (~> 3.1) 16 | erubis (~> 2.7.0) 17 | activemodel (4.1.1) 18 | activesupport (= 4.1.1) 19 | builder (~> 3.1) 20 | activerecord (4.1.1) 21 | activemodel (= 4.1.1) 22 | activesupport (= 4.1.1) 23 | arel (~> 5.0.0) 24 | activesupport (4.1.1) 25 | i18n (~> 0.6, >= 0.6.9) 26 | json (~> 1.7, >= 1.7.7) 27 | minitest (~> 5.1) 28 | thread_safe (~> 0.1) 29 | tzinfo (~> 1.1) 30 | amq-protocol (1.9.2) 31 | arel (5.0.1.20140414130214) 32 | builder (3.2.2) 33 | bunny (1.2.1) 34 | amq-protocol (>= 1.9.2) 35 | erubis (2.7.0) 36 | hike (1.2.3) 37 | i18n (0.6.9) 38 | json (1.8.1) 39 | mail (2.5.4) 40 | mime-types (~> 1.16) 41 | treetop (~> 1.4.8) 42 | mime-types (1.25.1) 43 | minitest (5.3.4) 44 | multi_json (1.10.0) 45 | polyglot (0.3.4) 46 | rack (1.5.2) 47 | rack-test (0.6.2) 48 | rack (>= 1.0) 49 | rails (4.1.1) 50 | actionmailer (= 4.1.1) 51 | actionpack (= 4.1.1) 52 | actionview (= 4.1.1) 53 | activemodel (= 4.1.1) 54 | activerecord (= 4.1.1) 55 | activesupport (= 4.1.1) 56 | bundler (>= 1.3.0, < 2.0) 57 | railties (= 4.1.1) 58 | sprockets-rails (~> 2.0) 59 | railties (4.1.1) 60 | actionpack (= 4.1.1) 61 | activesupport (= 4.1.1) 62 | rake (>= 0.8.7) 63 | thor (>= 0.18.1, < 2.0) 64 | rake (10.3.2) 65 | spring (1.1.3) 66 | sprockets (2.12.1) 67 | hike (~> 1.2) 68 | multi_json (~> 1.0) 69 | rack (~> 1.0) 70 | tilt (~> 1.1, != 1.3.0) 71 | sprockets-rails (2.1.3) 72 | actionpack (>= 3.0) 73 | activesupport (>= 3.0) 74 | sprockets (~> 2.8) 75 | sqlite3 (1.3.9) 76 | thor (0.19.1) 77 | thread_safe (0.3.3) 78 | tilt (1.4.1) 79 | treetop (1.4.15) 80 | polyglot 81 | polyglot (>= 0.3.1) 82 | tzinfo (1.1.0) 83 | thread_safe (~> 0.1) 84 | 85 | PLATFORMS 86 | ruby 87 | 88 | DEPENDENCIES 89 | bunny 90 | rails (= 4.1.1) 91 | spring 92 | sqlite3 93 | -------------------------------------------------------------------------------- /blog/Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec rails s -p 5001 2 | -------------------------------------------------------------------------------- /blog/README.rdoc: -------------------------------------------------------------------------------- 1 | == README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | 26 | 27 | Please feel free to use a different markup language if you do not plan to run 28 | rake doc:app. 29 | -------------------------------------------------------------------------------- /blog/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /blog/app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/blog/app/assets/images/.keep -------------------------------------------------------------------------------- /blog/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /blog/app/assets/stylesheets/scaffold.css: -------------------------------------------------------------------------------- 1 | body { background-color: #fff; color: #333; } 2 | 3 | body, p, ol, ul, td { 4 | font-family: verdana, arial, helvetica, sans-serif; 5 | font-size: 13px; 6 | line-height: 18px; 7 | } 8 | 9 | pre { 10 | background-color: #eee; 11 | padding: 10px; 12 | font-size: 11px; 13 | } 14 | 15 | a { color: #000; } 16 | a:visited { color: #666; } 17 | a:hover { color: #fff; background-color:#000; } 18 | 19 | div.field, div.actions { 20 | margin-bottom: 10px; 21 | } 22 | 23 | #notice { 24 | color: green; 25 | } 26 | 27 | .field_with_errors { 28 | padding: 2px; 29 | background-color: red; 30 | display: table; 31 | } 32 | 33 | #error_explanation { 34 | width: 450px; 35 | border: 2px solid red; 36 | padding: 7px; 37 | padding-bottom: 0; 38 | margin-bottom: 20px; 39 | background-color: #f0f0f0; 40 | } 41 | 42 | #error_explanation h2 { 43 | text-align: left; 44 | font-weight: bold; 45 | padding: 5px 5px 5px 15px; 46 | font-size: 12px; 47 | margin: -7px; 48 | margin-bottom: 0px; 49 | background-color: #c00; 50 | color: #fff; 51 | } 52 | 53 | #error_explanation ul li { 54 | font-size: 12px; 55 | list-style: square; 56 | } 57 | -------------------------------------------------------------------------------- /blog/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | 6 | before_action :publish_page_view 7 | 8 | protected 9 | 10 | def publish_page_view 11 | Publisher.publish("page_views", 12 | site: "blog", 13 | path: request.path, 14 | method: request.method 15 | ) 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /blog/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/blog/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /blog/app/controllers/posts_controller.rb: -------------------------------------------------------------------------------- 1 | class PostsController < ApplicationController 2 | before_action :set_post, only: [:show, :edit, :update, :destroy] 3 | 4 | # GET /posts 5 | def index 6 | @posts = Post.all 7 | end 8 | 9 | # GET /posts/1 10 | def show 11 | end 12 | 13 | # GET /posts/new 14 | def new 15 | @post = Post.new 16 | end 17 | 18 | # GET /posts/1/edit 19 | def edit 20 | end 21 | 22 | # POST /posts 23 | def create 24 | @post = Post.new(post_params) 25 | 26 | if @post.save 27 | Publisher.publish("posts", @post.attributes) 28 | redirect_to @post, notice: 'Post was successfully created.' 29 | else 30 | render :new 31 | end 32 | end 33 | 34 | # PATCH/PUT /posts/1 35 | def update 36 | if @post.update(post_params) 37 | Publisher.publish("posts", @post.attributes) 38 | redirect_to @post, notice: 'Post was successfully updated.' 39 | else 40 | render :edit 41 | end 42 | end 43 | 44 | # DELETE /posts/1 45 | def destroy 46 | @post.destroy 47 | redirect_to posts_url, notice: 'Post was successfully destroyed.' 48 | end 49 | 50 | private 51 | # Use callbacks to share common setup or constraints between actions. 52 | def set_post 53 | @post = Post.find(params[:id]) 54 | end 55 | 56 | # Only allow a trusted parameter "white list" through. 57 | def post_params 58 | params.require(:post).permit(:title, :body) 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /blog/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /blog/app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/blog/app/mailers/.keep -------------------------------------------------------------------------------- /blog/app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/blog/app/models/.keep -------------------------------------------------------------------------------- /blog/app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/blog/app/models/concerns/.keep -------------------------------------------------------------------------------- /blog/app/models/post.rb: -------------------------------------------------------------------------------- 1 | class Post < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /blog/app/services/publisher.rb: -------------------------------------------------------------------------------- 1 | class Publisher 2 | def self.publish(exchange, message = {}) 3 | x = channel.fanout("blog.#{exchange}") 4 | x.publish(message.to_json) 5 | end 6 | 7 | def self.channel 8 | @channel ||= connection.create_channel 9 | end 10 | 11 | def self.connection 12 | @connection ||= Bunny.new.tap do |c| 13 | c.start 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /blog/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Blog 5 | <%= stylesheet_link_tag 'application', media: 'all' %> 6 | <%= csrf_meta_tags %> 7 | 8 | 9 |

Blog

10 | 11 | <%= yield %> 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /blog/app/views/posts/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_for(@post) do |f| %> 2 | <% if @post.errors.any? %> 3 |
4 |

<%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:

5 | 6 | 11 |
12 | <% end %> 13 | 14 |
15 | <%= f.label :title %>
16 | <%= f.text_field :title %> 17 |
18 |
19 | <%= f.label :body %>
20 | <%= f.text_area :body %> 21 |
22 |
23 | <%= f.submit %> 24 |
25 | <% end %> 26 | -------------------------------------------------------------------------------- /blog/app/views/posts/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing post

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @post %> | 6 | <%= link_to 'Back', posts_path %> 7 | -------------------------------------------------------------------------------- /blog/app/views/posts/index.html.erb: -------------------------------------------------------------------------------- 1 |

Listing posts

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | <% @posts.each do |post| %> 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | <% end %> 22 | 23 |
TitleBody
<%= post.title %><%= post.body %><%= link_to 'Show', post %><%= link_to 'Edit', edit_post_path(post) %><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %>
24 | 25 |
26 | 27 | <%= link_to 'New Post', new_post_path %> 28 | -------------------------------------------------------------------------------- /blog/app/views/posts/new.html.erb: -------------------------------------------------------------------------------- 1 |

New post

2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Back', posts_path %> 6 | -------------------------------------------------------------------------------- /blog/app/views/posts/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

4 | Title: 5 | <%= @post.title %> 6 |

7 | 8 |

9 | Body: 10 | <%= @post.body %> 11 |

12 | 13 | <%= link_to 'Edit', edit_post_path(@post) %> | 14 | <%= link_to 'Back', posts_path %> 15 | -------------------------------------------------------------------------------- /blog/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /blog/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /blog/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /blog/bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast 4 | # It gets overwritten when you run the `spring binstub` command 5 | 6 | unless defined?(Spring) 7 | require "rubygems" 8 | require "bundler" 9 | 10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) 11 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) 12 | ENV["GEM_HOME"] = "" 13 | Gem.paths = ENV 14 | 15 | gem "spring", match[1] 16 | require "spring/binstub" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /blog/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /blog/config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | # Pick the frameworks you want: 4 | require "active_model/railtie" 5 | require "active_record/railtie" 6 | require "action_controller/railtie" 7 | require "action_mailer/railtie" 8 | require "action_view/railtie" 9 | require "sprockets/railtie" 10 | # require "rails/test_unit/railtie" 11 | 12 | # Require the gems listed in Gemfile, including any gems 13 | # you've limited to :test, :development, or :production. 14 | Bundler.require(*Rails.groups) 15 | 16 | module Blog 17 | class Application < Rails::Application 18 | # Settings in config/environments/* take precedence over those specified here. 19 | # Application configuration should go into files in config/initializers 20 | # -- all .rb files in that directory are automatically loaded. 21 | 22 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 23 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 24 | # config.time_zone = 'Central Time (US & Canada)' 25 | 26 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 27 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 28 | # config.i18n.default_locale = :de 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /blog/config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | 4 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) 5 | -------------------------------------------------------------------------------- /blog/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /blog/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /blog/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations. 23 | config.active_record.migration_error = :page_load 24 | 25 | 26 | # Raises error for missing translations 27 | # config.action_view.raise_on_missing_translations = true 28 | end 29 | -------------------------------------------------------------------------------- /blog/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. 20 | # config.action_dispatch.rack_cache = true 21 | 22 | # Disable Rails's static asset server (Apache or nginx will already do this). 23 | config.serve_static_assets = false 24 | 25 | 26 | # Specifies the header that your server uses for sending files. 27 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 28 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 29 | 30 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 31 | # config.force_ssl = true 32 | 33 | # Set to :debug to see everything in the log. 34 | config.log_level = :info 35 | 36 | # Prepend all log lines with the following tags. 37 | # config.log_tags = [ :subdomain, :uuid ] 38 | 39 | # Use a different logger for distributed setups. 40 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 41 | 42 | # Use a different cache store in production. 43 | # config.cache_store = :mem_cache_store 44 | 45 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 46 | # config.action_controller.asset_host = "http://assets.example.com" 47 | 48 | 49 | # Ignore bad email addresses and do not raise email delivery errors. 50 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 51 | # config.action_mailer.raise_delivery_errors = false 52 | 53 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 54 | # the I18n.default_locale when a translation cannot be found). 55 | config.i18n.fallbacks = true 56 | 57 | # Send deprecation notices to registered listeners. 58 | config.active_support.deprecation = :notify 59 | 60 | # Disable automatic flushing of the log to improve performance. 61 | # config.autoflush_log = false 62 | 63 | # Use default logging formatter so that PID and timestamp are not suppressed. 64 | config.log_formatter = ::Logger::Formatter.new 65 | 66 | # Do not dump schema after migrations. 67 | config.active_record.dump_schema_after_migration = false 68 | end 69 | -------------------------------------------------------------------------------- /blog/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static asset server for tests with Cache-Control for performance. 16 | config.serve_static_assets = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | 37 | # Raises error for missing translations 38 | # config.action_view.raise_on_missing_translations = true 39 | end 40 | -------------------------------------------------------------------------------- /blog/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /blog/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json -------------------------------------------------------------------------------- /blog/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /blog/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /blog/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /blog/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_blog_session' 4 | -------------------------------------------------------------------------------- /blog/config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /blog/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /blog/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | resources :posts 3 | 4 | root to: "posts#index" 5 | end 6 | -------------------------------------------------------------------------------- /blog/config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: 438d42867523e41acc102dcb3fae99894e49384879f8ef258e057fed99726019f4634d502577d87f2c73f055685fe316ea1ca22b93f64efbcf49907ab29bdc45 15 | 16 | test: 17 | secret_key_base: 995754b871d889aeceb9dffe36036b185a611e7b5888a593e0289ecd923fa7524c74fca152a00f43df4b238fa851e66462a18a75b1f0f312c6add07de9544677 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /blog/db/migrate/20140517222119_create_posts.rb: -------------------------------------------------------------------------------- 1 | class CreatePosts < ActiveRecord::Migration 2 | def change 3 | create_table :posts do |t| 4 | t.string :title 5 | t.text :body 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /blog/db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended that you check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(version: 20140517222119) do 15 | 16 | create_table "posts", force: true do |t| 17 | t.string "title" 18 | t.text "body" 19 | t.datetime "created_at" 20 | t.datetime "updated_at" 21 | end 22 | 23 | end 24 | -------------------------------------------------------------------------------- /blog/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /blog/lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/blog/lib/assets/.keep -------------------------------------------------------------------------------- /blog/lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/blog/lib/tasks/.keep -------------------------------------------------------------------------------- /blog/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/blog/log/.keep -------------------------------------------------------------------------------- /blog/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /blog/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /blog/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /blog/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/blog/public/favicon.ico -------------------------------------------------------------------------------- /blog/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /blog/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/blog/vendor/assets/stylesheets/.keep -------------------------------------------------------------------------------- /config/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'bunny' 4 | gem 'rake' 5 | -------------------------------------------------------------------------------- /config/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | amq-protocol (1.9.2) 5 | bunny (1.2.1) 6 | amq-protocol (>= 1.9.2) 7 | rake (10.4.2) 8 | 9 | PLATFORMS 10 | ruby 11 | 12 | DEPENDENCIES 13 | bunny 14 | rake 15 | -------------------------------------------------------------------------------- /config/Rakefile: -------------------------------------------------------------------------------- 1 | namespace :rabbitmq do 2 | desc "Setup routing" 3 | task :setup do 4 | require "bunny" 5 | 6 | conn = Bunny.new 7 | conn.start 8 | 9 | ch = conn.create_channel 10 | 11 | x = ch.fanout("blog.posts") 12 | ch.queue("dashboard.posts", durable: true).bind("blog.posts") 13 | ch.queue("admin.posts", durable: true).bind("blog.posts") 14 | 15 | x = ch.fanout("admin.page_views") 16 | ch.queue("dashboard.page_views", durable: true).bind("admin.page_views") 17 | 18 | x = ch.fanout("blog.page_views") 19 | ch.queue("dashboard.page_views", durable: true).bind("blog.page_views") 20 | 21 | conn.close 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /dashboard/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/*.log 16 | /tmp 17 | -------------------------------------------------------------------------------- /dashboard/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rails', '4.1.1' 4 | gem 'sqlite3' 5 | 6 | gem 'redis-rails' 7 | gem 'redis-namespace' 8 | 9 | gem 'sneakers' 10 | 11 | gem 'spring', group: :development 12 | -------------------------------------------------------------------------------- /dashboard/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (4.1.1) 5 | actionpack (= 4.1.1) 6 | actionview (= 4.1.1) 7 | mail (~> 2.5.4) 8 | actionpack (4.1.1) 9 | actionview (= 4.1.1) 10 | activesupport (= 4.1.1) 11 | rack (~> 1.5.2) 12 | rack-test (~> 0.6.2) 13 | actionview (4.1.1) 14 | activesupport (= 4.1.1) 15 | builder (~> 3.1) 16 | erubis (~> 2.7.0) 17 | activemodel (4.1.1) 18 | activesupport (= 4.1.1) 19 | builder (~> 3.1) 20 | activerecord (4.1.1) 21 | activemodel (= 4.1.1) 22 | activesupport (= 4.1.1) 23 | arel (~> 5.0.0) 24 | activesupport (4.1.1) 25 | i18n (~> 0.6, >= 0.6.9) 26 | json (~> 1.7, >= 1.7.7) 27 | minitest (~> 5.1) 28 | thread_safe (~> 0.1) 29 | tzinfo (~> 1.1) 30 | amq-protocol (1.9.2) 31 | arel (5.0.1.20140414130214) 32 | builder (3.2.2) 33 | bunny (1.2.1) 34 | amq-protocol (>= 1.9.2) 35 | erubis (2.7.0) 36 | hike (1.2.3) 37 | i18n (0.6.9) 38 | json (1.8.1) 39 | mail (2.5.4) 40 | mime-types (~> 1.16) 41 | treetop (~> 1.4.8) 42 | mime-types (1.25.1) 43 | minitest (5.3.4) 44 | multi_json (1.10.0) 45 | polyglot (0.3.4) 46 | rack (1.5.2) 47 | rack-test (0.6.2) 48 | rack (>= 1.0) 49 | rails (4.1.1) 50 | actionmailer (= 4.1.1) 51 | actionpack (= 4.1.1) 52 | actionview (= 4.1.1) 53 | activemodel (= 4.1.1) 54 | activerecord (= 4.1.1) 55 | activesupport (= 4.1.1) 56 | bundler (>= 1.3.0, < 2.0) 57 | railties (= 4.1.1) 58 | sprockets-rails (~> 2.0) 59 | railties (4.1.1) 60 | actionpack (= 4.1.1) 61 | activesupport (= 4.1.1) 62 | rake (>= 0.8.7) 63 | thor (>= 0.18.1, < 2.0) 64 | rake (10.3.2) 65 | redis (3.0.7) 66 | redis-actionpack (4.0.0) 67 | actionpack (~> 4) 68 | redis-rack (~> 1.5.0) 69 | redis-store (~> 1.1.0) 70 | redis-activesupport (4.0.0) 71 | activesupport (~> 4) 72 | redis-store (~> 1.1.0) 73 | redis-namespace (1.4.1) 74 | redis (~> 3.0.4) 75 | redis-rack (1.5.0) 76 | rack (~> 1.5) 77 | redis-store (~> 1.1.0) 78 | redis-rails (4.0.0) 79 | redis-actionpack (~> 4) 80 | redis-activesupport (~> 4) 81 | redis-store (~> 1.1.0) 82 | redis-store (1.1.4) 83 | redis (>= 2.2) 84 | serverengine (1.5.7) 85 | sigdump (~> 0.2.2) 86 | sigdump (0.2.2) 87 | sneakers (0.0.7) 88 | bunny (>= 0.10.0) 89 | serverengine 90 | thor 91 | thread 92 | spring (1.1.3) 93 | sprockets (2.12.1) 94 | hike (~> 1.2) 95 | multi_json (~> 1.0) 96 | rack (~> 1.0) 97 | tilt (~> 1.1, != 1.3.0) 98 | sprockets-rails (2.1.3) 99 | actionpack (>= 3.0) 100 | activesupport (>= 3.0) 101 | sprockets (~> 2.8) 102 | sqlite3 (1.3.9) 103 | thor (0.19.1) 104 | thread (0.1.3) 105 | thread_safe (0.3.3) 106 | tilt (1.4.1) 107 | treetop (1.4.15) 108 | polyglot 109 | polyglot (>= 0.3.1) 110 | tzinfo (1.1.0) 111 | thread_safe (~> 0.1) 112 | 113 | PLATFORMS 114 | ruby 115 | 116 | DEPENDENCIES 117 | rails (= 4.1.1) 118 | redis-namespace 119 | redis-rails 120 | sneakers 121 | spring 122 | sqlite3 123 | -------------------------------------------------------------------------------- /dashboard/Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec rails s -p 5002 2 | worker: env WORKERS=PostsWorker,PageViewsWorker bundle exec rake sneakers:run 3 | -------------------------------------------------------------------------------- /dashboard/README.rdoc: -------------------------------------------------------------------------------- 1 | == README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | 26 | 27 | Please feel free to use a different markup language if you do not plan to run 28 | rake doc:app. 29 | -------------------------------------------------------------------------------- /dashboard/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | require 'sneakers/tasks' 6 | 7 | Rails.application.load_tasks 8 | -------------------------------------------------------------------------------- /dashboard/app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/dashboard/app/assets/images/.keep -------------------------------------------------------------------------------- /dashboard/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /dashboard/app/assets/stylesheets/scaffold.css: -------------------------------------------------------------------------------- 1 | body { background-color: #fff; color: #333; } 2 | 3 | body, p, ol, ul, td { 4 | font-family: verdana, arial, helvetica, sans-serif; 5 | font-size: 13px; 6 | line-height: 18px; 7 | } 8 | 9 | pre { 10 | background-color: #eee; 11 | padding: 10px; 12 | font-size: 11px; 13 | } 14 | 15 | a { color: #000; } 16 | a:visited { color: #666; } 17 | a:hover { color: #fff; background-color:#000; } 18 | 19 | div.field, div.actions { 20 | margin-bottom: 10px; 21 | } 22 | 23 | #notice { 24 | color: green; 25 | } 26 | 27 | .field_with_errors { 28 | padding: 2px; 29 | background-color: red; 30 | display: table; 31 | } 32 | 33 | #error_explanation { 34 | width: 450px; 35 | border: 2px solid red; 36 | padding: 7px; 37 | padding-bottom: 0; 38 | margin-bottom: 20px; 39 | background-color: #f0f0f0; 40 | } 41 | 42 | #error_explanation h2 { 43 | text-align: left; 44 | font-weight: bold; 45 | padding: 5px 5px 5px 15px; 46 | font-size: 12px; 47 | margin: -7px; 48 | margin-bottom: 0px; 49 | background-color: #c00; 50 | color: #fff; 51 | } 52 | 53 | #error_explanation ul li { 54 | font-size: 12px; 55 | list-style: square; 56 | } 57 | -------------------------------------------------------------------------------- /dashboard/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /dashboard/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/dashboard/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /dashboard/app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | def index 3 | @posts = RecentPosts.list 4 | @page_views = PageViews.stats 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /dashboard/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /dashboard/app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/dashboard/app/mailers/.keep -------------------------------------------------------------------------------- /dashboard/app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/dashboard/app/models/.keep -------------------------------------------------------------------------------- /dashboard/app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/dashboard/app/models/concerns/.keep -------------------------------------------------------------------------------- /dashboard/app/services/page_views.rb: -------------------------------------------------------------------------------- 1 | class PageViews 2 | KEY = "page_views" 3 | 4 | def self.stats 5 | $redis.hgetall(KEY) 6 | end 7 | 8 | def self.record(raw_post) 9 | data = JSON.parse(raw_post) 10 | $redis.hincrby(KEY, data["site"], 1) 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /dashboard/app/services/recent_posts.rb: -------------------------------------------------------------------------------- 1 | class RecentPosts 2 | KEY = "recent_posts" 3 | STORE_LIMIT = 5 4 | 5 | def self.list(limit = STORE_LIMIT) 6 | $redis.lrange(KEY, 0, limit-1).map do |raw_post| 7 | JSON.parse(raw_post).with_indifferent_access 8 | end 9 | end 10 | 11 | def self.push(raw_post) 12 | $redis.lpush(KEY, raw_post) 13 | $redis.ltrim(KEY, 0, STORE_LIMIT-1) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /dashboard/app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

Recently updated posts

2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | <% @posts.each do |post| %> 12 | 13 | 14 | 15 | <% end %> 16 | 17 |
Title
<%= post[:title] %>
18 | 19 | 20 |

Page Views

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | <% @page_views.each do |site, count| %> 32 | 33 | 34 | 35 | 36 | <% end %> 37 | 38 |
SiteViews
<%= site %><%= count %>
39 | -------------------------------------------------------------------------------- /dashboard/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Dashboard 5 | <%= stylesheet_link_tag 'application', media: 'all' %> 6 | <%= csrf_meta_tags %> 7 | 8 | 9 |

Dashboard

10 | <%= yield %> 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /dashboard/app/workers/page_views_worker.rb: -------------------------------------------------------------------------------- 1 | class PageViewsWorker 2 | include Sneakers::Worker 3 | from_queue "dashboard.page_views", env: nil 4 | 5 | def work(raw_data) 6 | PageViews.record(raw_data) 7 | ack! 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /dashboard/app/workers/posts_worker.rb: -------------------------------------------------------------------------------- 1 | class PostsWorker 2 | include Sneakers::Worker 3 | from_queue "dashboard.posts", env: nil 4 | 5 | def work(raw_post) 6 | RecentPosts.push(raw_post) 7 | ack! 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /dashboard/bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /dashboard/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /dashboard/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /dashboard/bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast 4 | # It gets overwritten when you run the `spring binstub` command 5 | 6 | unless defined?(Spring) 7 | require "rubygems" 8 | require "bundler" 9 | 10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) 11 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) 12 | ENV["GEM_HOME"] = "" 13 | Gem.paths = ENV 14 | 15 | gem "spring", match[1] 16 | require "spring/binstub" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /dashboard/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /dashboard/config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | # Pick the frameworks you want: 4 | require "active_model/railtie" 5 | require "active_record/railtie" 6 | require "action_controller/railtie" 7 | require "action_mailer/railtie" 8 | require "action_view/railtie" 9 | require "sprockets/railtie" 10 | # require "rails/test_unit/railtie" 11 | 12 | # Require the gems listed in Gemfile, including any gems 13 | # you've limited to :test, :development, or :production. 14 | Bundler.require(*Rails.groups) 15 | 16 | module Dashboard 17 | class Application < Rails::Application 18 | # Settings in config/environments/* take precedence over those specified here. 19 | # Application configuration should go into files in config/initializers 20 | # -- all .rb files in that directory are automatically loaded. 21 | 22 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 23 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 24 | # config.time_zone = 'Central Time (US & Canada)' 25 | 26 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 27 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 28 | # config.i18n.default_locale = :de 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /dashboard/config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | 4 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) 5 | -------------------------------------------------------------------------------- /dashboard/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /dashboard/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /dashboard/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations. 23 | config.active_record.migration_error = :page_load 24 | 25 | 26 | # Raises error for missing translations 27 | # config.action_view.raise_on_missing_translations = true 28 | end 29 | -------------------------------------------------------------------------------- /dashboard/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. 20 | # config.action_dispatch.rack_cache = true 21 | 22 | # Disable Rails's static asset server (Apache or nginx will already do this). 23 | config.serve_static_assets = false 24 | 25 | 26 | # Specifies the header that your server uses for sending files. 27 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 28 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 29 | 30 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 31 | # config.force_ssl = true 32 | 33 | # Set to :debug to see everything in the log. 34 | config.log_level = :info 35 | 36 | # Prepend all log lines with the following tags. 37 | # config.log_tags = [ :subdomain, :uuid ] 38 | 39 | # Use a different logger for distributed setups. 40 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 41 | 42 | # Use a different cache store in production. 43 | # config.cache_store = :mem_cache_store 44 | 45 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 46 | # config.action_controller.asset_host = "http://assets.example.com" 47 | 48 | 49 | # Ignore bad email addresses and do not raise email delivery errors. 50 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 51 | # config.action_mailer.raise_delivery_errors = false 52 | 53 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 54 | # the I18n.default_locale when a translation cannot be found). 55 | config.i18n.fallbacks = true 56 | 57 | # Send deprecation notices to registered listeners. 58 | config.active_support.deprecation = :notify 59 | 60 | # Disable automatic flushing of the log to improve performance. 61 | # config.autoflush_log = false 62 | 63 | # Use default logging formatter so that PID and timestamp are not suppressed. 64 | config.log_formatter = ::Logger::Formatter.new 65 | 66 | # Do not dump schema after migrations. 67 | config.active_record.dump_schema_after_migration = false 68 | end 69 | -------------------------------------------------------------------------------- /dashboard/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static asset server for tests with Cache-Control for performance. 16 | config.serve_static_assets = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | 37 | # Raises error for missing translations 38 | # config.action_view.raise_on_missing_translations = true 39 | end 40 | -------------------------------------------------------------------------------- /dashboard/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /dashboard/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json -------------------------------------------------------------------------------- /dashboard/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /dashboard/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /dashboard/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /dashboard/config/initializers/redis.rb: -------------------------------------------------------------------------------- 1 | $redis = Redis::Namespace.new("dashboard:#{Rails.env}", redis: Redis.new) 2 | -------------------------------------------------------------------------------- /dashboard/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_dashboard_session' 4 | -------------------------------------------------------------------------------- /dashboard/config/initializers/sneakers.rb: -------------------------------------------------------------------------------- 1 | Sneakers.configure({}) 2 | Sneakers.logger.level = Logger::INFO 3 | -------------------------------------------------------------------------------- /dashboard/config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /dashboard/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /dashboard/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | root to: "home#index" 3 | end 4 | -------------------------------------------------------------------------------- /dashboard/config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: 5f86a8739b5680a94ff00fe207121c966b357870e20621d62c4c6712f078c57727c40a740eebe36466a43a763f5c50d6cd7cf3dd429723f5e55537dd7ac6a1d9 15 | 16 | test: 17 | secret_key_base: e9aa170e6cef86da8f6875ff481370cbf2270c4289f0790fa0249e0030a21a50e148a47ad52187eb061c99f1a00cad81295b776b12a542849adf3ee56b3ef0fc 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /dashboard/db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /dashboard/lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/dashboard/lib/assets/.keep -------------------------------------------------------------------------------- /dashboard/lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/dashboard/lib/tasks/.keep -------------------------------------------------------------------------------- /dashboard/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/dashboard/log/.keep -------------------------------------------------------------------------------- /dashboard/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /dashboard/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /dashboard/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /dashboard/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/dashboard/public/favicon.ico -------------------------------------------------------------------------------- /dashboard/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /dashboard/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monterail/rails-event-sourcing-example/ac34c06526d86b7f59aa3744a47f29191a445a29/dashboard/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------