├── log └── .keep ├── tmp └── .keep ├── .nvmrc ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── dist │ ├── css │ │ └── .keep │ └── js │ │ └── .keep ├── apple-touch-icon.png ├── apple-touch-icon-precomposed.png ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── test ├── helpers │ └── .keep ├── mailers │ └── .keep ├── models │ └── .keep ├── controllers │ ├── .keep │ └── home_controller_test.rb ├── fixtures │ ├── .keep │ └── files │ │ └── .keep ├── integration │ └── .keep └── test_helper.rb ├── app ├── assets │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── channels │ │ │ └── .keep │ │ ├── cable.js │ │ └── application.js │ ├── config │ │ └── manifest.js │ └── stylesheets │ │ └── application.css ├── models │ ├── concerns │ │ └── .keep │ └── application_record.rb ├── controllers │ ├── concerns │ │ └── .keep │ ├── application_controller.rb │ └── home_controller.rb ├── views │ ├── home │ │ └── index.html.erb │ └── layouts │ │ ├── mailer.text.erb │ │ ├── mailer.html.erb │ │ └── application.html.erb ├── helpers │ ├── home_helper.rb │ └── application_helper.rb ├── jobs │ └── application_job.rb ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb └── mailers │ └── application_mailer.rb ├── .ruby-version ├── vendor └── assets │ ├── javascripts │ └── .keep │ └── stylesheets │ └── .keep ├── .dockerignore ├── front ├── css │ ├── base │ │ ├── colors.scss │ │ └── typography.scss │ └── app.scss └── js │ ├── components │ ├── App.js │ └── Timestamp.js │ ├── utils │ └── logger.js │ ├── app.js │ └── hooks │ └── use-timestamp-provider.js ├── .stylelintrc ├── .prettierrc ├── bin ├── rake ├── bundle ├── rails ├── spring ├── update └── setup ├── config ├── spring.rb ├── boot.rb ├── initializers │ ├── session_store.rb │ ├── mime_types.rb │ ├── filter_parameter_logging.rb │ ├── application_controller_renderer.rb │ ├── cookies_serializer.rb │ ├── backtrace_silencers.rb │ ├── assets.rb │ ├── wrap_parameters.rb │ ├── asset_loader.rb │ ├── inflections.rb │ ├── new_framework_defaults.rb │ ├── content_security_policy.rb │ └── new_framework_defaults_6_0.rb ├── routes.rb ├── cable.yml ├── environment.rb ├── application.rb ├── locales │ └── en.yml ├── secrets.yml ├── storage.yml ├── puma.rb ├── environments │ ├── test.rb │ ├── development.rb │ └── production.rb └── database.yml ├── config.ru ├── .editorconfig ├── Rakefile ├── db ├── seeds.rb ├── migrate │ └── 20190817050131_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb └── schema.rb ├── Dockerfile ├── .eslintrc ├── .babelrc ├── .gitignore ├── webpack.config.js ├── LICENSE.md ├── webpack.config.base.js ├── webpack.config.prod.js ├── Gemfile ├── package.json ├── README.md └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 14.15.1 2 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/dist/css/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/dist/js/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | ruby-2.7.1 2 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/files/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | /log/* 2 | /tmp/* 3 | 4 | node_modules 5 | -------------------------------------------------------------------------------- /app/helpers/home_helper.rb: -------------------------------------------------------------------------------- 1 | module HomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /front/css/base/colors.scss: -------------------------------------------------------------------------------- 1 | $color-black: rgb(35, 31, 32); 2 | -------------------------------------------------------------------------------- /.stylelintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "stylelint-config-standard", 3 | } 4 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /front/css/app.scss: -------------------------------------------------------------------------------- 1 | @charset 'UTF-8'; 2 | 3 | @import 'base/colors'; 4 | @import 'base/typography'; 5 | -------------------------------------------------------------------------------- /front/css/base/typography.scss: -------------------------------------------------------------------------------- 1 | h1, 2 | h2, 3 | h3, 4 | h4, 5 | h5, 6 | p { 7 | color: $color-black; 8 | } 9 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | Spring.watch( 2 | ".ruby-version", 3 | ".rbenv-vars", 4 | "tmp/restart.txt", 5 | "tmp/caching-dev.txt" 6 | ) 7 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery with: :exception 3 | end 4 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../config/application', __dir__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | def asset_path(file, directory) 3 | return AssetLoader.get_asset_path(file, directory) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | def index 3 | end 4 | 5 | def timestamp 6 | render json: {timestamp: Time.now.to_i} 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /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: '_rails-react-boilerplate_session' 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | get 'home/index' 3 | get 'home/timestamp' 4 | 5 | root 'home#index' 6 | # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html 7 | end 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /test/controllers/home_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class HomeControllerTest < ActionDispatch::IntegrationTest 4 | test "should get index" do 5 | get home_index_url 6 | assert_response :success 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: rails_react_boilerplate_production 11 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ActiveSupport::Reloader.to_prepare do 4 | # ApplicationController.renderer.defaults.merge!( 5 | # http_host: 'example.org', 6 | # https: false 7 | # ) 8 | # end 9 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | 7 | Rails.application.config.assets.root_path = '/dist/' 8 | Rails.application.config.assets.manifest = 'public/dist/manifest.json' 9 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /front/js/components/App.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file App component. 3 | */ 4 | 5 | import React from 'react'; 6 | 7 | import Timestamp from './Timestamp'; 8 | 9 | const App = () => { 10 | return ( 11 |
12 |

Hello World!

13 | 14 | 15 |
16 | ); 17 | }; 18 | 19 | export default App; 20 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /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 rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 | # Character.create(name: 'Luke', movie: movies.first) 8 | -------------------------------------------------------------------------------- /front/js/utils/logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Frontend logger. 3 | */ 4 | 5 | import loglevel from 'loglevel'; 6 | import prefix from 'loglevel-plugin-prefix'; 7 | 8 | loglevel.setLevel(loglevel.levels.DEBUG); 9 | 10 | prefix.reg(loglevel); 11 | prefix.apply(loglevel, { template: '%t [%n] %l:' }); 12 | 13 | const getLogger = (name) => { 14 | return loglevel.getLogger(name); 15 | }; 16 | 17 | export default getLogger; 18 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.7.1-alpine 2 | 3 | RUN apk add --update --no-cache build-base ruby-dev tzdata postgresql-dev \ 4 | nodejs 5 | 6 | RUN mkdir -p /app 7 | WORKDIR /app 8 | 9 | ADD Gemfile . 10 | ADD Gemfile.lock . 11 | 12 | RUN gem install bundler && bundle install --without development test 13 | 14 | COPY . ./ 15 | 16 | ENV RAILS_ENV production 17 | 18 | EXPOSE 3000 19 | 20 | CMD ["rails", "server", "-b", "0.0.0.0"] 21 | -------------------------------------------------------------------------------- /app/assets/javascripts/cable.js: -------------------------------------------------------------------------------- 1 | // Action Cable provides the framework to deal with WebSockets in Rails. 2 | // You can generate new channels where WebSocket features live using the rails generate channel command. 3 | // 4 | //= require action_cable 5 | //= require_self 6 | //= require_tree ./channels 7 | 8 | (function() { 9 | this.App || (this.App = {}); 10 | 11 | App.cable = ActionCable.createConsumer(); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rails-react-boilerplate 5 | <%= csrf_meta_tags %> 6 | <%= stylesheet_link_tag asset_path('app.css', 'css'), media: 'all' %> 7 | 8 | 9 | 10 |
11 | <%= yield %> 12 | 13 | <%= javascript_include_tag asset_path('app.vendor.js', 'js') %> 14 | <%= javascript_include_tag asset_path('app.js', 'js') %> 15 | 16 | 17 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["airbnb", "plugin:prettier/recommended", "prettier/react"], 3 | "plugins": ["babel"], 4 | "parser": "babel-eslint", 5 | "env": { 6 | "browser": true 7 | }, 8 | "rules": { 9 | "arrow-body-style": 0, 10 | "camelcase": 0, 11 | "babel/camelcase": [ 12 | "error", 13 | { 14 | "properties": "always", 15 | "ignoreDestructuring": false 16 | } 17 | ], 18 | "react/jsx-filename-extension": 0, 19 | "react/require-default-props": 0 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /db/migrate/20190817050131_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.active_storage.rb: -------------------------------------------------------------------------------- 1 | # This migration comes from active_storage (originally 20180723000244) 2 | class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0] 3 | def up 4 | return if foreign_key_exists?(:active_storage_attachments, column: :blob_id) 5 | 6 | if table_exists?(:active_storage_blobs) 7 | add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "targets": { 7 | "browsers": ["last 2 versions"] 8 | }, 9 | "modules": false 10 | } 11 | ], 12 | "@babel/preset-react" 13 | ], 14 | "plugins": [ 15 | "@babel/plugin-proposal-class-properties", 16 | "@babel/plugin-proposal-object-rest-spread", 17 | "@babel/plugin-proposal-optional-chaining", 18 | "@babel/plugin-proposal-nullish-coalescing-operator" 19 | ], 20 | "only": ["front/js/*.js", "front/js/**/*.js"] 21 | } 22 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in the app/assets 11 | # folder are already added. 12 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 13 | -------------------------------------------------------------------------------- /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] 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 | -------------------------------------------------------------------------------- /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 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /front/js/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file App main entry point. 3 | */ 4 | 5 | import '@babel/polyfill'; 6 | 7 | import React from 'react'; 8 | import ReactDom from 'react-dom'; 9 | 10 | // Include the main scss file for webpack processing. 11 | import '../css/app.scss'; 12 | 13 | import App from './components/App'; 14 | import getLogger from './utils/logger'; 15 | 16 | const log = getLogger('App'); 17 | 18 | const init = () => { 19 | log.info('init() :: App starts booting...'); 20 | 21 | ReactDom.render(, document.getElementById('app')); 22 | }; 23 | 24 | // init app 25 | init(); 26 | -------------------------------------------------------------------------------- /front/js/components/Timestamp.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Timestamp component. 3 | */ 4 | 5 | import React, { useEffect } from 'react'; 6 | 7 | import useTimestampProvider from '../hooks/use-timestamp-provider'; 8 | 9 | const Timestamp = () => { 10 | const [timestamp, fetchTimestamp] = useTimestampProvider(); 11 | 12 | useEffect(() => { 13 | fetchTimestamp(); 14 | }, []); 15 | 16 | return ( 17 | <> 18 |

Timestamp: {timestamp}

19 | 22 | 23 | ); 24 | }; 25 | 26 | export default Timestamp; 27 | -------------------------------------------------------------------------------- /config/initializers/asset_loader.rb: -------------------------------------------------------------------------------- 1 | class AssetLoader 2 | def self.manifest 3 | return @manifest if defined?(@manifest) 4 | 5 | manifest_path = Rails.application.config.assets.manifest 6 | if File.exists?(manifest_path) 7 | @manifest = JSON.parse(File.read(manifest_path)) 8 | end 9 | end 10 | 11 | def self.get_asset_path(file, directory) 12 | root_path = Rails.application.config.assets.root_path 13 | file_path = nil 14 | 15 | if Rails.env.production? && AssetLoader.manifest 16 | file_path = AssetLoader.manifest[file] 17 | else 18 | file_path = "#{directory}/#{file}" 19 | end 20 | 21 | return root_path + file_path 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /front/js/hooks/use-timestamp-provider.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file TimestampProvider hook. 3 | */ 4 | 5 | import { useState } from 'react'; 6 | import axios from 'axios'; 7 | 8 | import getLogger from '../utils/logger'; 9 | 10 | const log = getLogger('TimestampProvider'); 11 | 12 | const useTimestampProvider = () => { 13 | const [timestamp, setTimestamp] = useState(null); 14 | 15 | const fetchTimestamp = async () => { 16 | try { 17 | const res = await axios.get('/home/timestamp'); 18 | 19 | setTimestamp(res.data.timestamp); 20 | } catch (error) { 21 | log.error(error); 22 | } 23 | }; 24 | 25 | return [timestamp, fetchTimestamp]; 26 | }; 27 | 28 | export default useTimestampProvider; 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module RailsReactBoilerplate 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 5.0 13 | 14 | # Settings in config/environments/* take precedence over those specified here. 15 | # Application configuration can go into files in config/initializers 16 | # -- all .rb files in that directory are automatically loaded after loading 17 | # the framework and any gems in your application. 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /.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 all logfiles and tempfiles. 11 | /log/* 12 | /tmp/* 13 | !/log/.keep 14 | !/tmp/.keep 15 | 16 | # Ignore Byebug command history file. 17 | .byebug_history 18 | 19 | .ruby-gemset 20 | node_modules 21 | 22 | public/dist/*.json 23 | 24 | public/dist/js/*.js 25 | public/dist/js/*.txt 26 | public/dist/js/*.map 27 | 28 | public/dist/css/*.css 29 | public/dist/css/*.map 30 | 31 | .vscode 32 | -------------------------------------------------------------------------------- /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 any plugin's vendor/assets/stylesheets directory 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 other CSS/SCSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require turbolinks 16 | //= require_tree . 17 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a way to update your development environment automatically. 15 | # Add necessary update steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | puts "\n== Updating database ==" 22 | system! 'bin/rails db:migrate' 23 | 24 | puts "\n== Removing old logs and tempfiles ==" 25 | system! 'bin/rails log:clear tmp:clear' 26 | 27 | puts "\n== Restarting application server ==" 28 | system! 'bin/rails restart' 29 | end 30 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Webpack configuration file for development. 3 | */ 4 | 5 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 6 | const StyleLintPlugin = require('stylelint-bare-webpack-plugin'); 7 | 8 | const config = require('./webpack.config.base'); 9 | 10 | config.mode = 'development'; 11 | 12 | config.output.filename = 'js/app.js'; 13 | 14 | config.plugins = [ 15 | new MiniCssExtractPlugin({ 16 | filename: 'css/app.css', 17 | }), 18 | new StyleLintPlugin({ 19 | syntax: 'scss', 20 | failOnError: true, 21 | }), 22 | ]; 23 | 24 | config.optimization = { 25 | runtimeChunk: false, 26 | splitChunks: { 27 | cacheGroups: { 28 | commons: { 29 | test: /[\\/]node_modules[\\/]/, 30 | name: 'app.vendor', 31 | filename: 'js/app.vendor.js', 32 | chunks: 'all', 33 | }, 34 | }, 35 | }, 36 | }; 37 | 38 | module.exports = config; 39 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # This file is the source Rails uses to define your schema when running `rails 6 | # db:schema:load`. When creating a new database, `rails db:schema:load` tends to 7 | # be faster and is potentially less error prone than running all of your 8 | # migrations from scratch. Old migrations may fail to apply correctly if those 9 | # migrations use external dependencies or application code. 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 2019_08_17_050131) do 14 | 15 | # These are extensions that must be enabled in order to support this database 16 | enable_extension "plpgsql" 17 | 18 | end 19 | -------------------------------------------------------------------------------- /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 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # 'true': 'foo' 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at https://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /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 `rails 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: 3a385c423d24dab917312f1aee32293a5091c7fdb5fdeb6fefde85f7c7abe020710954d9a6e37a79f5ff5593f800fbc2180e032715117d52d0a6edf02c597752 15 | 16 | test: 17 | secret_key_base: ae897caa9a387b025cf264a86d3c176a0c372b297807f85fc5ee31e6d2b7fb05bc159c189b5ab64eae8974ee0f93078ec253d280d1b401637ca0548e8810e966 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 | -------------------------------------------------------------------------------- /config/initializers/new_framework_defaults.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | # 3 | # This file contains migration options to ease your Rails 5.0 upgrade. 4 | # 5 | # Read the Guide for Upgrading Ruby on Rails for more info on each option. 6 | 7 | # Enable per-form CSRF tokens. Previous versions had false. 8 | Rails.application.config.action_controller.per_form_csrf_tokens = true 9 | 10 | # Enable origin-checking CSRF mitigation. Previous versions had false. 11 | Rails.application.config.action_controller.forgery_protection_origin_check = true 12 | 13 | # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. 14 | # Previous versions had false. 15 | ActiveSupport.to_time_preserves_timezone = true 16 | 17 | # Require `belongs_to` associations by default. Previous versions had false. 18 | Rails.application.config.active_record.belongs_to_required_by_default = true 19 | 20 | # Configure SSL options to enable HSTS with subdomains. Previous versions had false. 21 | Rails.application.config.ssl_options = { hsts: { subdomains: true } } 22 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path('..', __dir__) 6 | 7 | def system!(*args) 8 | system(*args) || abort("\n== Command #{args} failed ==") 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to setup or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at anytime and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # puts "\n== Copying sample files ==" 21 | # unless File.exist?('config/database.yml') 22 | # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' 23 | # end 24 | 25 | puts "\n== Preparing database ==" 26 | system! 'bin/rails db:prepare' 27 | 28 | puts "\n== Removing old logs and tempfiles ==" 29 | system! 'bin/rails log:clear tmp:clear' 30 | 31 | puts "\n== Restarting application server ==" 32 | system! 'bin/rails restart' 33 | end 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ioannis Poulakas http://www.ioannispoulakas.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket 23 | 24 | # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy 4 | # For further information see the following documentation 5 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy 6 | 7 | # Rails.application.config.content_security_policy do |policy| 8 | # policy.default_src :self, :https 9 | # policy.font_src :self, :https, :data 10 | # policy.img_src :self, :https, :data 11 | # policy.object_src :none 12 | # policy.script_src :self, :https 13 | # policy.style_src :self, :https 14 | 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | 19 | # If you are using UJS then enable automatic nonce generation 20 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } 21 | 22 | # Set the nonce only to specific directives 23 | # Rails.application.config.content_security_policy_nonce_directives = %w(script-src) 24 | 25 | # Report CSP violations to a specified URI 26 | # For further information see the following documentation: 27 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only 28 | # Rails.application.config.content_security_policy_report_only = true 29 | -------------------------------------------------------------------------------- /webpack.config.base.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Webpack basic configuration file. 3 | */ 4 | 5 | const path = require('path'); 6 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 7 | const autoprefixer = require('autoprefixer'); 8 | const cssnano = require('cssnano'); 9 | 10 | module.exports = { 11 | entry: { 12 | app: './front/js/app.js', 13 | }, 14 | output: { 15 | path: path.resolve(__dirname, 'public/dist'), 16 | }, 17 | devtool: 'source-map', 18 | module: { 19 | rules: [ 20 | { 21 | test: /\.js$/, 22 | exclude: /node_modules/, 23 | loader: 'eslint-loader', 24 | enforce: 'pre', 25 | query: { 26 | configFile: './.eslintrc', 27 | }, 28 | }, 29 | { 30 | test: /\.js$/, 31 | exclude: /node_modules/, 32 | loader: 'babel-loader', 33 | }, 34 | { 35 | test: /\.scss$/, 36 | use: [ 37 | MiniCssExtractPlugin.loader, 38 | { loader: 'css-loader', options: { sourceMap: true } }, 39 | { 40 | loader: 'postcss-loader', 41 | options: { 42 | postcssOptions: { 43 | plugins: () => [autoprefixer(), cssnano()], 44 | }, 45 | sourceMap: true, 46 | }, 47 | }, 48 | { loader: 'sass-loader', options: { sourceMap: true } }, 49 | ], 50 | }, 51 | ], 52 | }, 53 | }; 54 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } 9 | threads min_threads_count, max_threads_count 10 | 11 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 12 | # 13 | port ENV.fetch("PORT") { 3000 } 14 | 15 | # Specifies the `environment` that Puma will run in. 16 | # 17 | environment ENV.fetch("RAILS_ENV") { "development" } 18 | 19 | # Specifies the `pidfile` that Puma will use. 20 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 21 | 22 | # Specifies the number of `workers` to boot in clustered mode. 23 | # Workers are forked web server processes. If using threads and workers together 24 | # the concurrency of the application would be max `threads` * `workers`. 25 | # Workers do not work on JRuby or Windows (both of which do not support 26 | # processes). 27 | # 28 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 29 | 30 | # Use the `preload_app!` method when specifying a `workers` number. 31 | # This directive tells Puma to first boot the application and load code 32 | # before forking the application. This takes advantage of Copy On Write 33 | # process behavior so workers use less memory. 34 | # 35 | # preload_app! 36 | 37 | # Allow puma to be restarted by `rails restart` command. 38 | plugin :tmp_restart 39 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /webpack.config.prod.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Webpack configuration file for production. 3 | */ 4 | 5 | const webpack = require('webpack'); 6 | const TerserWebpackPlugin = require('terser-webpack-plugin'); 7 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 8 | const StyleLintPlugin = require('stylelint-bare-webpack-plugin'); 9 | const ManifestPlugin = require('webpack-manifest-plugin'); 10 | 11 | const config = require('./webpack.config.base'); 12 | 13 | config.mode = 'production'; 14 | 15 | config.output.filename = 'js/app.[chunkhash:8].js'; 16 | 17 | config.plugins = [ 18 | new webpack.DefinePlugin({ 19 | 'process.env': { 20 | NODE_ENV: JSON.stringify('production'), 21 | }, 22 | }), 23 | new MiniCssExtractPlugin({ 24 | filename: 'css/app.[chunkhash:8].css', 25 | }), 26 | new StyleLintPlugin({ 27 | syntax: 'scss', 28 | failOnError: true, 29 | }), 30 | new ManifestPlugin({ 31 | fileName: 'manifest.json', 32 | }), 33 | ]; 34 | 35 | config.optimization = { 36 | minimize: true, 37 | minimizer: [ 38 | new TerserWebpackPlugin({ 39 | terserOptions: { 40 | compress: { 41 | comparisons: false, 42 | warnings: false, 43 | }, 44 | mangle: { 45 | safari10: true, 46 | }, 47 | output: { 48 | comments: false, 49 | ascii_only: true, // eslint-disable-line babel/camelcase 50 | }, 51 | }, 52 | }), 53 | ], 54 | runtimeChunk: false, 55 | splitChunks: { 56 | cacheGroups: { 57 | commons: { 58 | test: /[\\/]node_modules[\\/]/, 59 | name: 'app.vendor', 60 | filename: 'js/app.vendor.[chunkhash:8].js', 61 | chunks: 'all', 62 | }, 63 | }, 64 | }, 65 | }; 66 | 67 | module.exports = config; 68 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | # The test environment is used exclusively to run your application's 2 | # test suite. You never need to work with it otherwise. Remember that 3 | # your test database is "scratch space" for the test suite and is wiped 4 | # and recreated between test runs. Don't rely on the data there! 5 | 6 | Rails.application.configure do 7 | # Settings specified here will take precedence over those in config/application.rb. 8 | 9 | config.cache_classes = false 10 | 11 | # Do not eager load code on boot. This avoids loading your whole application 12 | # just for the purpose of running a single test. If you are using a tool that 13 | # preloads Rails for running tests, you may have to set it to true. 14 | config.eager_load = false 15 | 16 | # Configure public file server for tests with Cache-Control for performance. 17 | config.public_file_server.enabled = true 18 | config.public_file_server.headers = { 19 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 20 | } 21 | 22 | # Show full error reports and disable caching. 23 | config.consider_all_requests_local = true 24 | config.action_controller.perform_caching = false 25 | config.cache_store = :null_store 26 | 27 | # Raise exceptions instead of rendering exception templates. 28 | config.action_dispatch.show_exceptions = false 29 | 30 | # Disable request forgery protection in test environment. 31 | config.action_controller.allow_forgery_protection = false 32 | 33 | # Store uploaded files on the local file system in a temporary directory. 34 | config.active_storage.service = :test 35 | 36 | config.action_mailer.perform_caching = false 37 | 38 | # Tell Action Mailer not to deliver emails to the real world. 39 | # The :test delivery method accumulates sent emails in the 40 | # ActionMailer::Base.deliveries array. 41 | config.action_mailer.delivery_method = :test 42 | 43 | # Print deprecation notices to the stderr. 44 | config.active_support.deprecation = :stderr 45 | 46 | # Raises error for missing translations. 47 | # config.action_view.raise_on_missing_translations = true 48 | end 49 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | ruby '2.7.1' 3 | 4 | git_source(:github) do |repo_name| 5 | repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 6 | "https://github.com/#{repo_name}.git" 7 | end 8 | 9 | 10 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 11 | gem 'rails', '~> 6.0.0' 12 | # Use postgresql as the database for Active Record 13 | gem 'pg', '~> 0.18' 14 | # Use Puma as the app server 15 | gem 'puma', '~> 4.3.1' 16 | # Use SCSS for stylesheets 17 | gem 'sass-rails', '~> 6.0.0' 18 | # Use Uglifier as compressor for JavaScript assets 19 | gem 'uglifier', '>= 4.1.20' 20 | # Use CoffeeScript for .coffee assets and views 21 | gem 'coffee-rails', '~> 5.0.0' 22 | # See https://github.com/rails/execjs#readme for more supported runtimes 23 | # gem 'therubyracer', platforms: :ruby 24 | 25 | # Use jquery as the JavaScript library 26 | gem 'jquery-rails' 27 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 28 | gem 'turbolinks', '~> 5' 29 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 30 | gem 'jbuilder', '~> 2.5' 31 | # Use Redis adapter to run Action Cable in production 32 | # gem 'redis', '~> 3.0' 33 | # Use ActiveModel has_secure_password 34 | # gem 'bcrypt', '~> 3.1.7' 35 | 36 | # Use Capistrano for deployment 37 | # gem 'capistrano-rails', group: :development 38 | 39 | group :development, :test do 40 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 41 | gem 'byebug', platform: :mri 42 | end 43 | 44 | group :development do 45 | # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 46 | gem 'web-console', '>= 3.3.0' 47 | gem 'listen', '~> 3.0.5' 48 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 49 | gem 'spring' 50 | gem 'spring-watcher-listen', '~> 2.0.0' 51 | end 52 | 53 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 54 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 55 | -------------------------------------------------------------------------------- /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. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | # Run rails dev:cache to toggle caching. 17 | if Rails.root.join('tmp', 'caching-dev.txt').exist? 18 | config.action_controller.perform_caching = true 19 | config.action_controller.enable_fragment_cache_logging = true 20 | 21 | config.cache_store = :memory_store 22 | config.public_file_server.headers = { 23 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 24 | } 25 | else 26 | config.action_controller.perform_caching = false 27 | 28 | config.cache_store = :null_store 29 | end 30 | 31 | # Store uploaded files on the local file system (see config/storage.yml for options). 32 | config.active_storage.service = :local 33 | 34 | # Don't care if the mailer can't send. 35 | config.action_mailer.raise_delivery_errors = false 36 | 37 | config.action_mailer.perform_caching = false 38 | 39 | # Print deprecation notices to the Rails logger. 40 | config.active_support.deprecation = :log 41 | 42 | # Raise an error on page load if there are pending migrations. 43 | config.active_record.migration_error = :page_load 44 | 45 | # Highlight code that triggered database queries in logs. 46 | config.active_record.verbose_query_logs = true 47 | 48 | # Debug mode disables concatenation and preprocessing of assets. 49 | # This option may cause significant delays in view rendering with a large 50 | # number of complex assets. 51 | config.assets.debug = true 52 | 53 | # Suppress logger output for asset requests. 54 | config.assets.quiet = true 55 | 56 | # Raises error for missing translations. 57 | # config.action_view.raise_on_missing_translations = true 58 | 59 | # Use an evented file watcher to asynchronously detect changes in source code, 60 | # routes, locales, etc. This feature depends on the listen gem. 61 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 62 | end 63 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rails-react-boilerplate", 3 | "version": "1.0.0", 4 | "description": "Rails / React / Webpack 2 boilerplate app.", 5 | "main": "index.js", 6 | "engines": { 7 | "node": "^14.15.1" 8 | }, 9 | "directories": { 10 | "test": "test" 11 | }, 12 | "scripts": { 13 | "test": "echo \"Error: no test specified\" && exit 1", 14 | "webpack": "node node_modules/webpack-cli/bin/cli.js --progress --colors", 15 | "webpack:watch": "node node_modules/webpack-cli/bin/cli.js --progress --colors --watch", 16 | "webpack:production": "node node_modules/webpack-cli/bin/cli.js --colors --config webpack.config.prod", 17 | "eslint": "node node_modules/eslint/bin/eslint.js front/js" 18 | }, 19 | "author": "IP", 20 | "license": "MIT", 21 | "repository": "giannisp/rails-react-boilerplate", 22 | "private": true, 23 | "dependencies": { 24 | "@babel/polyfill": "^7.12.1", 25 | "axios": "^0.21.1", 26 | "loglevel": "^1.7.1", 27 | "loglevel-plugin-prefix": "^0.8.4", 28 | "prop-types": "^15.7.2", 29 | "react": "^17.0.1", 30 | "react-dom": "^17.0.1", 31 | "sass": "^1.30.0" 32 | }, 33 | "devDependencies": { 34 | "@babel/core": "^7.12.10", 35 | "@babel/plugin-proposal-class-properties": "^7.12.1", 36 | "@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1", 37 | "@babel/plugin-proposal-object-rest-spread": "^7.12.1", 38 | "@babel/plugin-proposal-optional-chaining": "^7.12.7", 39 | "@babel/preset-env": "^7.12.11", 40 | "@babel/preset-react": "^7.12.10", 41 | "autoprefixer": "^10.1.0", 42 | "babel-eslint": "^10.1.0", 43 | "babel-loader": "^8.2.2", 44 | "css-loader": "^5.0.1", 45 | "cssnano": "^4.1.10", 46 | "eslint": "^7.16.0", 47 | "eslint-config-airbnb": "^18.2.1", 48 | "eslint-config-prettier": "^7.1.0", 49 | "eslint-loader": "^4.0.2", 50 | "eslint-plugin-babel": "^5.3.1", 51 | "eslint-plugin-import": "^2.22.1", 52 | "eslint-plugin-jsx-a11y": "^6.4.1", 53 | "eslint-plugin-prettier": "^3.3.0", 54 | "eslint-plugin-react": "^7.21.5", 55 | "eslint-plugin-react-hooks": "^4.2.0", 56 | "mini-css-extract-plugin": "^1.3.3", 57 | "node-sass": "^5.0.0", 58 | "postcss": "^8.2.1", 59 | "postcss-loader": "^4.1.0", 60 | "prettier": "^2.2.1", 61 | "sass-loader": "^10.1.0", 62 | "style-loader": "^2.0.0", 63 | "stylelint": "^13.8.0", 64 | "stylelint-bare-webpack-plugin": "^2.1.0", 65 | "stylelint-config-standard": "^20.0.0", 66 | "terser-webpack-plugin": "^4.2.2", 67 | "webpack": "^4.44.2", 68 | "webpack-cli": "^3.3.12", 69 | "webpack-manifest-plugin": "^2.2.0" 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /config/initializers/new_framework_defaults_6_0.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | # 3 | # This file contains migration options to ease your Rails 6.0 upgrade. 4 | # 5 | # Once upgraded flip defaults one by one to migrate to the new default. 6 | # 7 | # Read the Guide for Upgrading Ruby on Rails for more info on each option. 8 | 9 | # Don't force requests from old versions of IE to be UTF-8 encoded. 10 | # Rails.application.config.action_view.default_enforce_utf8 = false 11 | 12 | # Embed purpose and expiry metadata inside signed and encrypted 13 | # cookies for increased security. 14 | # 15 | # This option is not backwards compatible with earlier Rails versions. 16 | # It's best enabled when your entire app is migrated and stable on 6.0. 17 | # Rails.application.config.action_dispatch.use_cookies_with_metadata = true 18 | 19 | # Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification. 20 | # Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false 21 | 22 | # Return false instead of self when enqueuing is aborted from a callback. 23 | # Rails.application.config.active_job.return_false_on_aborted_enqueue = true 24 | 25 | # Send Active Storage analysis and purge jobs to dedicated queues. 26 | # Rails.application.config.active_storage.queues.analysis = :active_storage_analysis 27 | # Rails.application.config.active_storage.queues.purge = :active_storage_purge 28 | 29 | # When assigning to a collection of attachments declared via `has_many_attached`, replace existing 30 | # attachments instead of appending. Use #attach to add new attachments without replacing existing ones. 31 | # Rails.application.config.active_storage.replace_on_assign_to_many = true 32 | 33 | # Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail. 34 | # 35 | # The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob), 36 | # will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions. 37 | # If you send mail in the background, job workers need to have a copy of 38 | # MailDeliveryJob to ensure all delivery jobs are processed properly. 39 | # Make sure your entire app is migrated and stable on 6.0 before using this setting. 40 | # Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" 41 | 42 | # Enable the same cache key to be reused when the object being cached of type 43 | # `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count) 44 | # of the relation's cache key into the cache version to support recycling cache key. 45 | # Rails.application.config.active_record.collection_cache_versioning = true 46 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 9.1 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On OS X with Homebrew: 6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7 | # On OS X with MacPorts: 8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 9 | # On Windows: 10 | # gem install pg 11 | # Choose the win32 build. 12 | # Install PostgreSQL and put its /bin directory on your path. 13 | # 14 | # Configure Using Gemfile 15 | # gem 'pg' 16 | # 17 | default: &default 18 | adapter: postgresql 19 | encoding: unicode 20 | # For details on connection pooling, see rails configuration guide 21 | # http://guides.rubyonrails.org/configuring.html#database-pooling 22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 23 | 24 | development: 25 | <<: *default 26 | database: rails-react-bp-dev 27 | 28 | # The specified database role being used to connect to postgres. 29 | # To create additional roles in postgres see `$ createuser --help`. 30 | # When left blank, postgres will use the default role. This is 31 | # the same name as the operating system user that initialized the database. 32 | #username: rails-react-boilerplate 33 | 34 | # The password associated with the postgres role (username). 35 | #password: 36 | 37 | # Connect on a TCP socket. Omitted by default since the client uses a 38 | # domain socket that doesn't need configuration. Windows does not have 39 | # domain sockets, so uncomment these lines. 40 | #host: localhost 41 | 42 | # The TCP port the server listens on. Defaults to 5432. 43 | # If your server runs on a different port number, change accordingly. 44 | #port: 5432 45 | 46 | # Schema search path. The server defaults to $user,public 47 | #schema_search_path: myapp,sharedapp,public 48 | 49 | # Minimum log levels, in increasing order: 50 | # debug5, debug4, debug3, debug2, debug1, 51 | # log, notice, warning, error, fatal, and panic 52 | # Defaults to warning. 53 | #min_messages: notice 54 | 55 | # Warning: The database defined as "test" will be erased and 56 | # re-generated from your development database when you run "rake". 57 | # Do not set this db to the same as development or production. 58 | test: 59 | <<: *default 60 | database: rails-react-bp-test 61 | 62 | # As with config/secrets.yml, you never want to store sensitive information, 63 | # like your database password, in your source code. If your source code is 64 | # ever seen by anyone, they now have access to your database. 65 | # 66 | # Instead, provide the password as a unix environment variable when you boot 67 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 68 | # for a full rundown on how to provide these environment variables in a 69 | # production deployment. 70 | # 71 | # On Heroku and other platform providers, you may have a full connection URL 72 | # available as an environment variable. For example: 73 | # 74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 75 | # 76 | # You can use this database configuration with: 77 | # 78 | # production: 79 | # url: <%= ENV['DATABASE_URL'] %> 80 | # 81 | production: 82 | <<: *default 83 | database: rails-react-bp-prod 84 | username: rails-react-boilerplate 85 | password: <%= ENV['RAILS-REACT-BOILERPLATE_DATABASE_PASSWORD'] %> 86 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rails-react-boilerplate 2 | 3 | This is a pure [Ruby on Rails](http://rubyonrails.org/) / [React](https://facebook.github.io/react/) / [Webpack 4](https://webpack.js.org/) boilerplate app. 4 | 5 | ## Features 6 | 7 | - Ruby on Rails 6.x 8 | - React 16.x 9 | - Webpack 4.x 10 | - Babel 7.x 11 | - ESLint support 12 | - Prettier support 13 | - SASS and StyleLint support 14 | - Hashed filenames for production assets 15 | - Separate app and vendor JS bundles 16 | - Postgres compatibility 17 | - Using Rails default gems and NPM packages only 18 | 19 | ## Exit Asset Pipeline, Enter Webpack 20 | 21 | Why Webpack? 22 | Webpack is a module bundler. It can bundle all JS files for usage in the browser, but can also transform / bundle / package any resource or frontend asset. 23 | The [NPM](https://www.npmjs.com/) ecosystem is huge, and Webpack makes it available in the simplest way possible. 24 | Webpack can support every modern JS app, using ES6 or CommonJS modules, or both, create a single or multiple bundles, and in general can be customized to accomplish any application requirement. 25 | 26 | The frontend assets on this repository are placed on a more accessible directory, at `front/js` and `front/css`, rather than `app/assets/javascripts` and `app/assets/stylesheets`. 27 | At any point, migration to a different backend (for example NodeJS) can be seamless since Webpack is running as a stand-alone bundler, there's absolutely no dependence to the Asset Pipeline or any other framework-specific module. 28 | 29 | ## Install 30 | 31 | It's recommended to use Ruby 2.7.1 and NodeJS 12.x. 32 | 33 | ```sh 34 | # install bundler if not available 35 | gem install bundler 36 | 37 | # install gem dependencies 38 | bundle install 39 | 40 | # install npm dependencies 41 | npm install 42 | 43 | # create the postgres databases 44 | # update config/database.yml details if needed 45 | rake db:create 46 | 47 | # generate assets for development 48 | npm run webpack 49 | 50 | # start server 51 | rails s 52 | ``` 53 | 54 | ## Webpack scripts 55 | 56 | `npm run webpack` 57 | Builds the assets for development mode. 58 | 59 | `npm run webpack:watch` 60 | Builds the assets for development mode, and rebuilds on every detected change. 61 | 62 | `npm run webpack:production` 63 | Builds the assets for production mode, output files are hashed. 64 | 65 | ## Load assets in production from a custom root directory or URL 66 | 67 | By default JS/CSS assets are being served from the `public/dist` directory. However in production it may be needed to serve assets from a CDN or an S3 bucket etc. 68 | Simply override the `Rails.application.config.assets.root_path` property on the production environment to accomplish it. 69 | Of course during the deployment script and after the `npm run webpack-production` command, `public/dist/*` output files should be copied to the target dir or infrastructure. 70 | 71 | ## Run in production 72 | 73 | ``` 74 | # build assets 75 | npm run webpack:production 76 | 77 | # run rails server 78 | SECRET_KEY_BASE=abcd RAILS_SERVE_STATIC_FILES=true rails s -e production 79 | ``` 80 | 81 | ## Run in Docker (optional) 82 | 83 | Repository contains a basic Dockerfile for running the app in production mode. 84 | Assets should be compiled first using webpack outside of the container. 85 | 86 | ```sh 87 | # build docker image 88 | docker build -t rails-react-boilerplate . 89 | 90 | # run docker image 91 | docker run -p 3000:3000 -e SECRET_KEY_BASE=abcd rails-react-boilerplate 92 | ``` 93 | -------------------------------------------------------------------------------- /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 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 18 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 19 | # config.require_master_key = true 20 | 21 | # Disable serving static files from the `/public` folder by default since 22 | # Apache or NGINX already handles this. 23 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 24 | 25 | # Compress CSS using a preprocessor. 26 | # config.assets.css_compressor = :sass 27 | 28 | # Do not fallback to assets pipeline if a precompiled asset is missed. 29 | config.assets.compile = false 30 | 31 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 32 | # config.action_controller.asset_host = 'http://assets.example.com' 33 | 34 | # Specifies the header that your server uses for sending files. 35 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 36 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 37 | 38 | # Store uploaded files on the local file system (see config/storage.yml for options). 39 | config.active_storage.service = :local 40 | 41 | # Mount Action Cable outside main process or domain. 42 | # config.action_cable.mount_path = nil 43 | # config.action_cable.url = 'wss://example.com/cable' 44 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 45 | 46 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 47 | # config.force_ssl = true 48 | 49 | # Use the lowest log level to ensure availability of diagnostic information 50 | # when problems arise. 51 | config.log_level = :debug 52 | 53 | # Prepend all log lines with the following tags. 54 | config.log_tags = [ :request_id ] 55 | 56 | # Use a different cache store in production. 57 | # config.cache_store = :mem_cache_store 58 | 59 | # Use a real queuing backend for Active Job (and separate queues per environment). 60 | # config.active_job.queue_adapter = :resque 61 | # config.active_job.queue_name_prefix = "rails_react_boilerplate_production" 62 | 63 | config.action_mailer.perform_caching = false 64 | 65 | # Ignore bad email addresses and do not raise email delivery errors. 66 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 67 | # config.action_mailer.raise_delivery_errors = false 68 | 69 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 70 | # the I18n.default_locale when a translation cannot be found). 71 | config.i18n.fallbacks = true 72 | 73 | # Send deprecation notices to registered listeners. 74 | config.active_support.deprecation = :notify 75 | 76 | # Use default logging formatter so that PID and timestamp are not suppressed. 77 | config.log_formatter = ::Logger::Formatter.new 78 | 79 | # Use a different logger for distributed setups. 80 | # require 'syslog/logger' 81 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 82 | 83 | if ENV["RAILS_LOG_TO_STDOUT"].present? 84 | logger = ActiveSupport::Logger.new(STDOUT) 85 | logger.formatter = config.log_formatter 86 | config.logger = ActiveSupport::TaggedLogging.new(logger) 87 | end 88 | 89 | # Do not dump schema after migrations. 90 | config.active_record.dump_schema_after_migration = false 91 | 92 | # Inserts middleware to perform automatic connection switching. 93 | # The `database_selector` hash is used to pass options to the DatabaseSelector 94 | # middleware. The `delay` is used to determine how long to wait after a write 95 | # to send a subsequent read to the primary. 96 | # 97 | # The `database_resolver` class is used by the middleware to determine which 98 | # database is appropriate to use based on the time delay. 99 | # 100 | # The `database_resolver_context` class is used by the middleware to set 101 | # timestamps for the last write to the primary. The resolver uses the context 102 | # class timestamps to determine how long to wait before reading from the 103 | # replica. 104 | # 105 | # By default Rails will store a last write timestamp in the session. The 106 | # DatabaseSelector middleware is designed as such you can define your own 107 | # strategy for connection switching and pass that into the middleware through 108 | # these configuration options. 109 | # config.active_record.database_selector = { delay: 2.seconds } 110 | # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver 111 | # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session 112 | end 113 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (6.0.3.3) 5 | actionpack (= 6.0.3.3) 6 | nio4r (~> 2.0) 7 | websocket-driver (>= 0.6.1) 8 | actionmailbox (6.0.3.3) 9 | actionpack (= 6.0.3.3) 10 | activejob (= 6.0.3.3) 11 | activerecord (= 6.0.3.3) 12 | activestorage (= 6.0.3.3) 13 | activesupport (= 6.0.3.3) 14 | mail (>= 2.7.1) 15 | actionmailer (6.0.3.3) 16 | actionpack (= 6.0.3.3) 17 | actionview (= 6.0.3.3) 18 | activejob (= 6.0.3.3) 19 | mail (~> 2.5, >= 2.5.4) 20 | rails-dom-testing (~> 2.0) 21 | actionpack (6.0.3.3) 22 | actionview (= 6.0.3.3) 23 | activesupport (= 6.0.3.3) 24 | rack (~> 2.0, >= 2.0.8) 25 | rack-test (>= 0.6.3) 26 | rails-dom-testing (~> 2.0) 27 | rails-html-sanitizer (~> 1.0, >= 1.2.0) 28 | actiontext (6.0.3.3) 29 | actionpack (= 6.0.3.3) 30 | activerecord (= 6.0.3.3) 31 | activestorage (= 6.0.3.3) 32 | activesupport (= 6.0.3.3) 33 | nokogiri (>= 1.8.5) 34 | actionview (6.0.3.3) 35 | activesupport (= 6.0.3.3) 36 | builder (~> 3.1) 37 | erubi (~> 1.4) 38 | rails-dom-testing (~> 2.0) 39 | rails-html-sanitizer (~> 1.1, >= 1.2.0) 40 | activejob (6.0.3.3) 41 | activesupport (= 6.0.3.3) 42 | globalid (>= 0.3.6) 43 | activemodel (6.0.3.3) 44 | activesupport (= 6.0.3.3) 45 | activerecord (6.0.3.3) 46 | activemodel (= 6.0.3.3) 47 | activesupport (= 6.0.3.3) 48 | activestorage (6.0.3.3) 49 | actionpack (= 6.0.3.3) 50 | activejob (= 6.0.3.3) 51 | activerecord (= 6.0.3.3) 52 | marcel (~> 0.3.1) 53 | activesupport (6.0.3.3) 54 | concurrent-ruby (~> 1.0, >= 1.0.2) 55 | i18n (>= 0.7, < 2) 56 | minitest (~> 5.1) 57 | tzinfo (~> 1.1) 58 | zeitwerk (~> 2.2, >= 2.2.2) 59 | bindex (0.8.1) 60 | builder (3.2.4) 61 | byebug (11.1.3) 62 | coffee-rails (5.0.0) 63 | coffee-script (>= 2.2.0) 64 | railties (>= 5.2.0) 65 | coffee-script (2.4.1) 66 | coffee-script-source 67 | execjs 68 | coffee-script-source (1.12.2) 69 | concurrent-ruby (1.1.7) 70 | crass (1.0.6) 71 | erubi (1.9.0) 72 | execjs (2.7.0) 73 | ffi (1.13.1) 74 | globalid (0.4.2) 75 | activesupport (>= 4.2.0) 76 | i18n (1.8.5) 77 | concurrent-ruby (~> 1.0) 78 | jbuilder (2.10.1) 79 | activesupport (>= 5.0.0) 80 | jquery-rails (4.4.0) 81 | rails-dom-testing (>= 1, < 3) 82 | railties (>= 4.2.0) 83 | thor (>= 0.14, < 2.0) 84 | listen (3.0.8) 85 | rb-fsevent (~> 0.9, >= 0.9.4) 86 | rb-inotify (~> 0.9, >= 0.9.7) 87 | loofah (2.7.0) 88 | crass (~> 1.0.2) 89 | nokogiri (>= 1.5.9) 90 | mail (2.7.1) 91 | mini_mime (>= 0.1.1) 92 | marcel (0.3.3) 93 | mimemagic (~> 0.3.2) 94 | method_source (1.0.0) 95 | mimemagic (0.3.5) 96 | mini_mime (1.0.2) 97 | mini_portile2 (2.4.0) 98 | minitest (5.14.2) 99 | nio4r (2.5.4) 100 | nokogiri (1.10.10) 101 | mini_portile2 (~> 2.4.0) 102 | pg (0.21.0) 103 | puma (4.3.6) 104 | nio4r (~> 2.0) 105 | rack (2.2.3) 106 | rack-test (1.1.0) 107 | rack (>= 1.0, < 3) 108 | rails (6.0.3.3) 109 | actioncable (= 6.0.3.3) 110 | actionmailbox (= 6.0.3.3) 111 | actionmailer (= 6.0.3.3) 112 | actionpack (= 6.0.3.3) 113 | actiontext (= 6.0.3.3) 114 | actionview (= 6.0.3.3) 115 | activejob (= 6.0.3.3) 116 | activemodel (= 6.0.3.3) 117 | activerecord (= 6.0.3.3) 118 | activestorage (= 6.0.3.3) 119 | activesupport (= 6.0.3.3) 120 | bundler (>= 1.3.0) 121 | railties (= 6.0.3.3) 122 | sprockets-rails (>= 2.0.0) 123 | rails-dom-testing (2.0.3) 124 | activesupport (>= 4.2.0) 125 | nokogiri (>= 1.6) 126 | rails-html-sanitizer (1.3.0) 127 | loofah (~> 2.3) 128 | railties (6.0.3.3) 129 | actionpack (= 6.0.3.3) 130 | activesupport (= 6.0.3.3) 131 | method_source 132 | rake (>= 0.8.7) 133 | thor (>= 0.20.3, < 2.0) 134 | rake (13.0.1) 135 | rb-fsevent (0.10.4) 136 | rb-inotify (0.10.1) 137 | ffi (~> 1.0) 138 | sass-rails (6.0.0) 139 | sassc-rails (~> 2.1, >= 2.1.1) 140 | sassc (2.4.0) 141 | ffi (~> 1.9) 142 | sassc-rails (2.1.2) 143 | railties (>= 4.0.0) 144 | sassc (>= 2.0) 145 | sprockets (> 3.0) 146 | sprockets-rails 147 | tilt 148 | spring (2.1.1) 149 | spring-watcher-listen (2.0.1) 150 | listen (>= 2.7, < 4.0) 151 | spring (>= 1.2, < 3.0) 152 | sprockets (4.0.2) 153 | concurrent-ruby (~> 1.0) 154 | rack (> 1, < 3) 155 | sprockets-rails (3.2.2) 156 | actionpack (>= 4.0) 157 | activesupport (>= 4.0) 158 | sprockets (>= 3.0.0) 159 | thor (1.0.1) 160 | thread_safe (0.3.6) 161 | tilt (2.0.10) 162 | turbolinks (5.2.1) 163 | turbolinks-source (~> 5.2) 164 | turbolinks-source (5.2.0) 165 | tzinfo (1.2.7) 166 | thread_safe (~> 0.1) 167 | uglifier (4.2.0) 168 | execjs (>= 0.3.0, < 3) 169 | web-console (4.0.4) 170 | actionview (>= 6.0.0) 171 | activemodel (>= 6.0.0) 172 | bindex (>= 0.4.0) 173 | railties (>= 6.0.0) 174 | websocket-driver (0.7.3) 175 | websocket-extensions (>= 0.1.0) 176 | websocket-extensions (0.1.5) 177 | zeitwerk (2.4.0) 178 | 179 | PLATFORMS 180 | ruby 181 | 182 | DEPENDENCIES 183 | byebug 184 | coffee-rails (~> 5.0.0) 185 | jbuilder (~> 2.5) 186 | jquery-rails 187 | listen (~> 3.0.5) 188 | pg (~> 0.18) 189 | puma (~> 4.3.1) 190 | rails (~> 6.0.0) 191 | sass-rails (~> 6.0.0) 192 | spring 193 | spring-watcher-listen (~> 2.0.0) 194 | turbolinks (~> 5) 195 | tzinfo-data 196 | uglifier (>= 4.1.20) 197 | web-console (>= 3.3.0) 198 | 199 | RUBY VERSION 200 | ruby 2.7.1p83 201 | 202 | BUNDLED WITH 203 | 2.1.4 204 | --------------------------------------------------------------------------------