├── .codeclimate.yml ├── .env.example ├── .gitignore ├── .rspec ├── .rubocop.yml ├── .ruby-version ├── Gemfile ├── Gemfile.lock ├── LICENSE.md ├── Procfile ├── README.md ├── Rakefile ├── app ├── assets │ ├── config │ │ └── manifest.js │ ├── images │ │ ├── .keep │ │ ├── rails.svg │ │ └── welcome.png │ ├── javascripts │ │ ├── application.js.es6 │ │ ├── cable.js.es6 │ │ ├── channels │ │ │ └── .keep │ │ └── views │ │ │ └── home.js.es6 │ └── stylesheets │ │ ├── application.scss │ │ ├── common │ │ ├── fonts.scss │ │ └── variables.scss │ │ └── views │ │ ├── home.scss │ │ └── layout.scss ├── calculations │ └── application_calculation.rb ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ └── home_controller.rb ├── decorators │ ├── application_decorator.rb │ └── paginating_decorator.rb ├── forms │ └── application_form.rb ├── helpers │ └── application_helper.rb ├── jobs │ └── application_job.rb ├── mailers │ └── application_mailer.rb ├── models │ ├── application_record.rb │ ├── concerns │ │ └── .keep │ └── user.rb ├── policies │ └── application_policy.rb ├── queries │ └── application_query.rb ├── services │ └── application_service.rb ├── uploaders │ └── file_uploader.rb ├── validators │ └── .keep ├── value_objects │ └── application_value_object.rb └── views │ ├── devise │ ├── confirmations │ │ └── new.html.slim │ ├── mailer │ │ ├── confirmation_instructions.html.slim │ │ ├── email_changed.html.slim │ │ ├── password_change.html.slim │ │ ├── reset_password_instructions.html.slim │ │ └── unlock_instructions.html.slim │ ├── passwords │ │ ├── edit.html.slim │ │ └── new.html.slim │ ├── registrations │ │ ├── edit.html.slim │ │ └── new.html.slim │ ├── sessions │ │ └── new.html.slim │ ├── shared │ │ ├── _error_messages.html.slim │ │ └── _links.html.slim │ └── unlocks │ │ └── new.html.slim │ ├── home │ └── index.html.slim │ ├── layouts │ ├── application.html.slim │ ├── mailer.html.slim │ └── mailer.text.slim │ └── shared │ └── layouts │ └── _flash.html.slim ├── bin ├── bundle ├── rails ├── rake ├── setup ├── spring ├── update └── yarn ├── config.ru ├── config ├── application.rb ├── boot.rb ├── cable.yml ├── credentials.yml.enc ├── database.yml.sample ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── application_controller_renderer.rb │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── carrierwave.rb │ ├── content_security_policy.rb │ ├── cookies_serializer.rb │ ├── devise.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── kaminari_config.rb │ ├── mime_types.rb │ ├── rack_mini_profiler.rb │ ├── sentry.rb │ ├── sidekiq.rb │ ├── simple_form.rb │ ├── wicked_pdf.rb │ └── wrap_parameters.rb ├── locales │ ├── devise.en.yml │ ├── en.yml │ ├── pundit.en.yml │ └── simple_form.en.yml ├── puma.rb ├── routes.rb ├── sidekiq.yml ├── spring.rb └── storage.yml ├── db ├── migrate │ └── 20190601095148_devise_create_users.rb ├── schema.rb └── seeds.rb ├── docs └── pull_request_template.md ├── lib ├── assets │ └── .keep ├── tasks │ ├── .keep │ └── auto_annotate_models.rake └── templates │ └── erb │ └── scaffold │ └── _form.html.erb ├── log └── .keep ├── package.json ├── public ├── 404.html ├── 422.html ├── 500.html ├── apple-touch-icon-precomposed.png ├── apple-touch-icon.png ├── favicon.ico └── robots.txt ├── spec ├── controllers │ └── home_controller_spec.rb ├── factories │ └── users.rb ├── models │ └── user_spec.rb ├── rails_helper.rb ├── spec_helper.rb └── support │ ├── devise.rb │ ├── factory_bot_rails.rb │ ├── json_parser.rb │ ├── matchers │ ├── axlsx_matcher.rb │ ├── be_url_matcher.rb │ ├── have_attrs_matcher.rb │ ├── not_change_matcher.rb │ └── redirect_via_turbolinks_to_matcher.rb │ ├── shared_contexts │ └── axlsx.rb │ └── shoulda_matchers.rb ├── storage └── .keep ├── tmp └── .keep └── vendor └── .keep /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | brakeman: 3 | enabled: true 4 | bundler-audit: 5 | enabled: true 6 | coffeelint: 7 | enabled: true 8 | duplication: 9 | enabled: true 10 | config: 11 | languages: 12 | - javascript 13 | - ruby 14 | exclude_paths: 15 | - 'app/controllers/' 16 | eslint: 17 | enabled: true 18 | fixme: 19 | enabled: true 20 | rubocop: 21 | enabled: true 22 | ratings: 23 | paths: 24 | - 'app/**' 25 | - 'lib/**' 26 | exclude_paths: 27 | - 'config/' 28 | - 'db/' 29 | - 'public/' 30 | - 'spec/' 31 | - 'vendor/' 32 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | HOST=localhost:3000 2 | REDIS_URL=redis://127.0.0.1:6379 3 | 4 | AWS_ACCESS_KEY_ID= 5 | AWS_ACCESS_KEY_ID= 6 | AWS_STORE_BUCKET= 7 | AWS_REGION= 8 | CURRENT_ENVIRONMENT= 9 | SENTRY_DSN= 10 | -------------------------------------------------------------------------------- /.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/* 16 | /tmp/* 17 | !/log/.keep 18 | !/tmp/.keep 19 | 20 | # Ignore uploaded files in development 21 | /storage/* 22 | !/storage/.keep 23 | 24 | /node_modules 25 | /yarn-error.log 26 | 27 | /public/assets 28 | .byebug_history 29 | 30 | # Ignore master key for decrypting credentials and more. 31 | /config/master.key 32 | 33 | # Ignore public assets 34 | /public/assets/ 35 | 36 | # Ignore .env 37 | /.env 38 | 39 | # Ignore coverage 40 | coverage/**/* 41 | 42 | config/database.yml 43 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | --drb 3 | --format Fuubar 4 | --color 5 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | require: rubocop-rails 2 | 3 | AllCops: 4 | TargetRubyVersion: 2.4 5 | Exclude: 6 | - .gems/**/* 7 | - bin/**/* 8 | - config/**/* 9 | - db/**/* 10 | - log/**/* 11 | - public/**/* 12 | - tmp/**/* 13 | - vendor/**/* 14 | - spec/rails_helper.rb 15 | - spec/spec_helper.rb 16 | - config.ru 17 | - Guardfile 18 | - Rakefile 19 | 20 | Bundler/OrderedGems: 21 | Enabled: false 22 | 23 | Layout/AlignParameters: 24 | EnforcedStyle: with_fixed_indentation 25 | 26 | Layout/MultilineMethodCallIndentation: 27 | EnforcedStyle: indented 28 | 29 | Layout/SpaceInsidePercentLiteralDelimiters: 30 | Enabled: false 31 | 32 | Naming/AccessorMethodName: 33 | Enabled: false 34 | 35 | Style/AndOr: 36 | Enabled: false 37 | 38 | Style/ClassAndModuleChildren: 39 | Enabled: false 40 | 41 | Style/Documentation: 42 | Enabled: false 43 | 44 | Style/FrozenStringLiteralComment: 45 | Enabled: false 46 | 47 | Style/GuardClause: 48 | Enabled: false 49 | 50 | Style/IfUnlessModifier: 51 | Enabled: false 52 | 53 | Style/MutableConstant: 54 | Enabled: true 55 | 56 | Style/Semicolon: 57 | AllowAsExpressionSeparator: true 58 | 59 | Style/SingleLineBlockParams: 60 | Enabled: false 61 | 62 | Metrics/AbcSize: 63 | Max: 30 64 | 65 | Metrics/BlockNesting: 66 | Max: 4 67 | 68 | Metrics/BlockLength: 69 | Max: 50 70 | 71 | Metrics/ClassLength: 72 | Max: 250 73 | 74 | Metrics/ModuleLength: 75 | Max: 250 76 | 77 | Metrics/LineLength: 78 | Enabled: false 79 | 80 | Metrics/MethodLength: 81 | Max: 30 82 | 83 | Metrics/ParameterLists: 84 | Enabled: false 85 | 86 | Rails: 87 | Enabled: true 88 | 89 | Rails/Delegate: 90 | Enabled: false 91 | 92 | Rails/HasAndBelongsToMany: 93 | Enabled: false 94 | 95 | Rails/HttpPositionalArguments: 96 | Enabled: false 97 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.6.3 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby '2.6.3' 5 | 6 | # Server 7 | gem 'rails', '~> 5.2.3' 8 | gem 'puma', '~> 3.11' 9 | gem 'bootsnap', '>= 1.1.0', require: false 10 | 11 | # Database and Model 12 | gem 'pg' 13 | gem 'aasm' 14 | gem 'value_objects', git: 'https://github.com/GoldenOwlAsia/value_objects.git' 15 | 16 | # Asset pipeline 17 | gem 'sass-rails', '~> 5.0' 18 | gem 'coffee-rails', '~> 4.2' 19 | gem 'uglifier', '>= 1.3.0' 20 | 21 | # View render 22 | gem 'slim' 23 | gem 'simple_form' 24 | gem 'country_select' 25 | gem 'kaminari' 26 | 27 | # Pdf render 28 | gem 'wicked_pdf' 29 | gem 'wkhtmltopdf-binary' 30 | 31 | # Xlsx render 32 | # gem 'axlsx', git: 'https://github.com/randym/axlsx.git' 33 | # gem 'axlsx_rails' 34 | 35 | # Mailer 36 | gem 'premailer-rails' 37 | 38 | # Front-end 39 | gem 'turbolinks', '~> 5' 40 | gem 'sprockets', '>= 3.0.0' 41 | gem 'sprockets-es6' 42 | gem 'punchbox', git: 'https://github.com/GoldenOwlAsia/punchbox.git' 43 | gem 'bootstrap', '~> 4.3.1' 44 | gem 'jquery-rails' 45 | 46 | # File uploading 47 | gem 'mini_magick' 48 | gem 'carrierwave', '~> 1.0' 49 | gem 'fog-aws' 50 | 51 | # Authentication 52 | gem 'devise' 53 | 54 | # Background worker 55 | # gem 'sidekiq-cron', '~> 1.1' 56 | # gem 'whenever', require: false 57 | gem 'sidekiq' 58 | 59 | # Patterns 60 | gem 'draper' 61 | gem 'pundit' 62 | 63 | # Performance 64 | gem 'rack-mini-profiler', require: false 65 | 66 | # 3rd services 67 | gem 'sentry-raven' 68 | 69 | group :development, :test do 70 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 71 | gem 'pry-rails' 72 | gem 'dotenv-rails' 73 | gem 'rspec-rails', '~> 3.8' 74 | gem 'factory_bot_rails' 75 | gem 'fuubar' 76 | gem 'faker' 77 | end 78 | 79 | group :development do 80 | gem 'web-console', '>= 3.3.0' 81 | gem 'listen', '>= 3.0.5', '< 3.2' 82 | gem 'spring' 83 | gem 'spring-watcher-listen', '~> 2.0.0' 84 | gem 'rubocop-rails' 85 | gem 'letter_opener' 86 | gem 'annotate' 87 | gem 'bullet' 88 | end 89 | 90 | group :test do 91 | gem 'simplecov', require: false 92 | gem 'capybara', '>= 2.15' 93 | gem 'selenium-webdriver' 94 | gem 'chromedriver-helper' 95 | gem 'shoulda-matchers' 96 | gem 'rails-controller-testing' 97 | gem 'webmock' 98 | gem 'vcr' 99 | end 100 | 101 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 102 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: https://github.com/GoldenOwlAsia/punchbox.git 3 | revision: fb078b9758e3c1b7efc76884e688719333b82d24 4 | specs: 5 | punchbox (1.0.4) 6 | rails (>= 4.0.0) 7 | 8 | GIT 9 | remote: https://github.com/GoldenOwlAsia/value_objects.git 10 | revision: 06f13f1aca37e4b9e36678aa26e23afd23183029 11 | specs: 12 | value_objects (1.0.0) 13 | activerecord (>= 4.2, <= 5.2.3) 14 | 15 | GEM 16 | remote: https://rubygems.org/ 17 | specs: 18 | aasm (5.0.5) 19 | concurrent-ruby (~> 1.0) 20 | actioncable (5.2.3) 21 | actionpack (= 5.2.3) 22 | nio4r (~> 2.0) 23 | websocket-driver (>= 0.6.1) 24 | actionmailer (5.2.3) 25 | actionpack (= 5.2.3) 26 | actionview (= 5.2.3) 27 | activejob (= 5.2.3) 28 | mail (~> 2.5, >= 2.5.4) 29 | rails-dom-testing (~> 2.0) 30 | actionpack (5.2.3) 31 | actionview (= 5.2.3) 32 | activesupport (= 5.2.3) 33 | rack (~> 2.0) 34 | rack-test (>= 0.6.3) 35 | rails-dom-testing (~> 2.0) 36 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 37 | actionview (5.2.3) 38 | activesupport (= 5.2.3) 39 | builder (~> 3.1) 40 | erubi (~> 1.4) 41 | rails-dom-testing (~> 2.0) 42 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 43 | activejob (5.2.3) 44 | activesupport (= 5.2.3) 45 | globalid (>= 0.3.6) 46 | activemodel (5.2.3) 47 | activesupport (= 5.2.3) 48 | activemodel-serializers-xml (1.0.2) 49 | activemodel (> 5.x) 50 | activesupport (> 5.x) 51 | builder (~> 3.1) 52 | activerecord (5.2.3) 53 | activemodel (= 5.2.3) 54 | activesupport (= 5.2.3) 55 | arel (>= 9.0) 56 | activestorage (5.2.3) 57 | actionpack (= 5.2.3) 58 | activerecord (= 5.2.3) 59 | marcel (~> 0.3.1) 60 | activesupport (5.2.3) 61 | concurrent-ruby (~> 1.0, >= 1.0.2) 62 | i18n (>= 0.7, < 2) 63 | minitest (~> 5.1) 64 | tzinfo (~> 1.1) 65 | addressable (2.6.0) 66 | public_suffix (>= 2.0.2, < 4.0) 67 | annotate (2.7.5) 68 | activerecord (>= 3.2, < 7.0) 69 | rake (>= 10.4, < 13.0) 70 | archive-zip (0.12.0) 71 | io-like (~> 0.3.0) 72 | arel (9.0.0) 73 | ast (2.4.0) 74 | autoprefixer-rails (9.6.0) 75 | execjs 76 | babel-source (5.8.35) 77 | babel-transpiler (0.7.0) 78 | babel-source (>= 4.0, < 6) 79 | execjs (~> 2.0) 80 | bcrypt (3.1.13) 81 | bindex (0.7.0) 82 | bootsnap (1.4.4) 83 | msgpack (~> 1.0) 84 | bootstrap (4.3.1) 85 | autoprefixer-rails (>= 9.1.0) 86 | popper_js (>= 1.14.3, < 2) 87 | sassc-rails (>= 2.0.0) 88 | builder (3.2.3) 89 | bullet (6.0.0) 90 | activesupport (>= 3.0.0) 91 | uniform_notifier (~> 1.11) 92 | byebug (11.0.1) 93 | capybara (3.23.0) 94 | addressable 95 | mini_mime (>= 0.1.3) 96 | nokogiri (~> 1.8) 97 | rack (>= 1.6.0) 98 | rack-test (>= 0.6.3) 99 | regexp_parser (~> 1.5) 100 | xpath (~> 3.2) 101 | carrierwave (1.3.1) 102 | activemodel (>= 4.0.0) 103 | activesupport (>= 4.0.0) 104 | mime-types (>= 1.16) 105 | childprocess (1.0.1) 106 | rake (< 13.0) 107 | chromedriver-helper (2.1.1) 108 | archive-zip (~> 0.10) 109 | nokogiri (~> 1.8) 110 | coderay (1.1.2) 111 | coffee-rails (4.2.2) 112 | coffee-script (>= 2.2.0) 113 | railties (>= 4.0.0) 114 | coffee-script (2.4.1) 115 | coffee-script-source 116 | execjs 117 | coffee-script-source (1.12.2) 118 | concurrent-ruby (1.1.5) 119 | connection_pool (2.2.2) 120 | countries (3.0.0) 121 | i18n_data (~> 0.8.0) 122 | sixarm_ruby_unaccent (~> 1.1) 123 | unicode_utils (~> 1.4) 124 | country_select (4.0.0) 125 | countries (~> 3.0) 126 | sort_alphabetical (~> 1.0) 127 | crack (0.4.3) 128 | safe_yaml (~> 1.0.0) 129 | crass (1.0.4) 130 | css_parser (1.7.0) 131 | addressable 132 | devise (4.6.2) 133 | bcrypt (~> 3.0) 134 | orm_adapter (~> 0.1) 135 | railties (>= 4.1.0, < 6.0) 136 | responders 137 | warden (~> 1.2.3) 138 | diff-lcs (1.3) 139 | docile (1.3.2) 140 | dotenv (2.7.2) 141 | dotenv-rails (2.7.2) 142 | dotenv (= 2.7.2) 143 | railties (>= 3.2, < 6.1) 144 | draper (3.1.0) 145 | actionpack (>= 5.0) 146 | activemodel (>= 5.0) 147 | activemodel-serializers-xml (>= 1.0) 148 | activesupport (>= 5.0) 149 | request_store (>= 1.0) 150 | erubi (1.8.0) 151 | excon (0.64.0) 152 | execjs (2.7.0) 153 | factory_bot (5.0.2) 154 | activesupport (>= 4.2.0) 155 | factory_bot_rails (5.0.2) 156 | factory_bot (~> 5.0.2) 157 | railties (>= 4.2.0) 158 | faker (1.9.3) 159 | i18n (>= 0.7) 160 | faraday (0.15.4) 161 | multipart-post (>= 1.2, < 3) 162 | ffi (1.11.1) 163 | fog-aws (3.5.1) 164 | fog-core (~> 2.1) 165 | fog-json (~> 1.1) 166 | fog-xml (~> 0.1) 167 | ipaddress (~> 0.8) 168 | fog-core (2.1.2) 169 | builder 170 | excon (~> 0.58) 171 | formatador (~> 0.2) 172 | mime-types 173 | fog-json (1.2.0) 174 | fog-core 175 | multi_json (~> 1.10) 176 | fog-xml (0.1.3) 177 | fog-core 178 | nokogiri (>= 1.5.11, < 2.0.0) 179 | formatador (0.2.5) 180 | fuubar (2.4.1) 181 | rspec-core (~> 3.0) 182 | ruby-progressbar (~> 1.4) 183 | globalid (0.4.2) 184 | activesupport (>= 4.2.0) 185 | hashdiff (0.4.0) 186 | htmlentities (4.3.4) 187 | i18n (1.6.0) 188 | concurrent-ruby (~> 1.0) 189 | i18n_data (0.8.0) 190 | io-like (0.3.0) 191 | ipaddress (0.8.3) 192 | jaro_winkler (1.5.3) 193 | jquery-rails (4.3.3) 194 | rails-dom-testing (>= 1, < 3) 195 | railties (>= 4.2.0) 196 | thor (>= 0.14, < 2.0) 197 | json (2.2.0) 198 | kaminari (1.1.1) 199 | activesupport (>= 4.1.0) 200 | kaminari-actionview (= 1.1.1) 201 | kaminari-activerecord (= 1.1.1) 202 | kaminari-core (= 1.1.1) 203 | kaminari-actionview (1.1.1) 204 | actionview 205 | kaminari-core (= 1.1.1) 206 | kaminari-activerecord (1.1.1) 207 | activerecord 208 | kaminari-core (= 1.1.1) 209 | kaminari-core (1.1.1) 210 | launchy (2.4.3) 211 | addressable (~> 2.3) 212 | letter_opener (1.7.0) 213 | launchy (~> 2.2) 214 | listen (3.1.5) 215 | rb-fsevent (~> 0.9, >= 0.9.4) 216 | rb-inotify (~> 0.9, >= 0.9.7) 217 | ruby_dep (~> 1.2) 218 | loofah (2.2.3) 219 | crass (~> 1.0.2) 220 | nokogiri (>= 1.5.9) 221 | mail (2.7.1) 222 | mini_mime (>= 0.1.1) 223 | marcel (0.3.3) 224 | mimemagic (~> 0.3.2) 225 | method_source (0.9.2) 226 | mime-types (3.2.2) 227 | mime-types-data (~> 3.2015) 228 | mime-types-data (3.2019.0331) 229 | mimemagic (0.3.3) 230 | mini_magick (4.9.3) 231 | mini_mime (1.0.1) 232 | mini_portile2 (2.4.0) 233 | minitest (5.11.3) 234 | msgpack (1.2.10) 235 | multi_json (1.13.1) 236 | multipart-post (2.1.1) 237 | nio4r (2.3.1) 238 | nokogiri (1.10.3) 239 | mini_portile2 (~> 2.4.0) 240 | orm_adapter (0.5.0) 241 | parallel (1.17.0) 242 | parser (2.6.3.0) 243 | ast (~> 2.4.0) 244 | pg (1.1.4) 245 | popper_js (1.14.5) 246 | premailer (1.11.1) 247 | addressable 248 | css_parser (>= 1.6.0) 249 | htmlentities (>= 4.0.0) 250 | premailer-rails (1.10.2) 251 | actionmailer (>= 3, < 6) 252 | premailer (~> 1.7, >= 1.7.9) 253 | pry (0.12.2) 254 | coderay (~> 1.1.0) 255 | method_source (~> 0.9.0) 256 | pry-rails (0.3.9) 257 | pry (>= 0.10.4) 258 | public_suffix (3.1.0) 259 | puma (3.12.1) 260 | pundit (2.0.1) 261 | activesupport (>= 3.0.0) 262 | rack (2.0.7) 263 | rack-mini-profiler (1.0.2) 264 | rack (>= 1.2.0) 265 | rack-protection (2.0.5) 266 | rack 267 | rack-test (1.1.0) 268 | rack (>= 1.0, < 3) 269 | rails (5.2.3) 270 | actioncable (= 5.2.3) 271 | actionmailer (= 5.2.3) 272 | actionpack (= 5.2.3) 273 | actionview (= 5.2.3) 274 | activejob (= 5.2.3) 275 | activemodel (= 5.2.3) 276 | activerecord (= 5.2.3) 277 | activestorage (= 5.2.3) 278 | activesupport (= 5.2.3) 279 | bundler (>= 1.3.0) 280 | railties (= 5.2.3) 281 | sprockets-rails (>= 2.0.0) 282 | rails-controller-testing (1.0.4) 283 | actionpack (>= 5.0.1.x) 284 | actionview (>= 5.0.1.x) 285 | activesupport (>= 5.0.1.x) 286 | rails-dom-testing (2.0.3) 287 | activesupport (>= 4.2.0) 288 | nokogiri (>= 1.6) 289 | rails-html-sanitizer (1.0.4) 290 | loofah (~> 2.2, >= 2.2.2) 291 | railties (5.2.3) 292 | actionpack (= 5.2.3) 293 | activesupport (= 5.2.3) 294 | method_source 295 | rake (>= 0.8.7) 296 | thor (>= 0.19.0, < 2.0) 297 | rainbow (3.0.0) 298 | rake (12.3.2) 299 | rb-fsevent (0.10.3) 300 | rb-inotify (0.10.0) 301 | ffi (~> 1.0) 302 | redis (4.1.2) 303 | regexp_parser (1.5.1) 304 | request_store (1.4.1) 305 | rack (>= 1.4) 306 | responders (2.4.1) 307 | actionpack (>= 4.2.0, < 6.0) 308 | railties (>= 4.2.0, < 6.0) 309 | rspec-core (3.8.0) 310 | rspec-support (~> 3.8.0) 311 | rspec-expectations (3.8.4) 312 | diff-lcs (>= 1.2.0, < 2.0) 313 | rspec-support (~> 3.8.0) 314 | rspec-mocks (3.8.0) 315 | diff-lcs (>= 1.2.0, < 2.0) 316 | rspec-support (~> 3.8.0) 317 | rspec-rails (3.8.2) 318 | actionpack (>= 3.0) 319 | activesupport (>= 3.0) 320 | railties (>= 3.0) 321 | rspec-core (~> 3.8.0) 322 | rspec-expectations (~> 3.8.0) 323 | rspec-mocks (~> 3.8.0) 324 | rspec-support (~> 3.8.0) 325 | rspec-support (3.8.0) 326 | rubocop (0.72.0) 327 | jaro_winkler (~> 1.5.1) 328 | parallel (~> 1.10) 329 | parser (>= 2.6) 330 | rainbow (>= 2.2.2, < 4.0) 331 | ruby-progressbar (~> 1.7) 332 | unicode-display_width (>= 1.4.0, < 1.7) 333 | rubocop-rails (2.1.0) 334 | rack (>= 1.1) 335 | rubocop (>= 0.72.0) 336 | ruby-progressbar (1.10.1) 337 | ruby_dep (1.5.0) 338 | rubyzip (1.2.3) 339 | safe_yaml (1.0.5) 340 | sass (3.7.4) 341 | sass-listen (~> 4.0.0) 342 | sass-listen (4.0.0) 343 | rb-fsevent (~> 0.9, >= 0.9.4) 344 | rb-inotify (~> 0.9, >= 0.9.7) 345 | sass-rails (5.0.7) 346 | railties (>= 4.0.0, < 6) 347 | sass (~> 3.1) 348 | sprockets (>= 2.8, < 4.0) 349 | sprockets-rails (>= 2.0, < 4.0) 350 | tilt (>= 1.1, < 3) 351 | sassc (2.0.1) 352 | ffi (~> 1.9) 353 | rake 354 | sassc-rails (2.1.1) 355 | railties (>= 4.0.0) 356 | sassc (>= 2.0) 357 | sprockets (> 3.0) 358 | sprockets-rails 359 | tilt 360 | selenium-webdriver (3.142.3) 361 | childprocess (>= 0.5, < 2.0) 362 | rubyzip (~> 1.2, >= 1.2.2) 363 | sentry-raven (2.9.0) 364 | faraday (>= 0.7.6, < 1.0) 365 | shoulda-matchers (4.0.1) 366 | activesupport (>= 4.2.0) 367 | sidekiq (5.2.7) 368 | connection_pool (~> 2.2, >= 2.2.2) 369 | rack (>= 1.5.0) 370 | rack-protection (>= 1.5.0) 371 | redis (>= 3.3.5, < 5) 372 | simple_form (4.1.0) 373 | actionpack (>= 5.0) 374 | activemodel (>= 5.0) 375 | simplecov (0.16.1) 376 | docile (~> 1.1) 377 | json (>= 1.8, < 3) 378 | simplecov-html (~> 0.10.0) 379 | simplecov-html (0.10.2) 380 | sixarm_ruby_unaccent (1.2.0) 381 | slim (4.0.1) 382 | temple (>= 0.7.6, < 0.9) 383 | tilt (>= 2.0.6, < 2.1) 384 | sort_alphabetical (1.1.0) 385 | unicode_utils (>= 1.2.2) 386 | spring (2.0.2) 387 | activesupport (>= 4.2) 388 | spring-watcher-listen (2.0.1) 389 | listen (>= 2.7, < 4.0) 390 | spring (>= 1.2, < 3.0) 391 | sprockets (3.7.2) 392 | concurrent-ruby (~> 1.0) 393 | rack (> 1, < 3) 394 | sprockets-es6 (0.9.2) 395 | babel-source (>= 5.8.11) 396 | babel-transpiler 397 | sprockets (>= 3.0.0) 398 | sprockets-rails (3.2.1) 399 | actionpack (>= 4.0) 400 | activesupport (>= 4.0) 401 | sprockets (>= 3.0.0) 402 | temple (0.8.1) 403 | thor (0.20.3) 404 | thread_safe (0.3.6) 405 | tilt (2.0.9) 406 | turbolinks (5.2.0) 407 | turbolinks-source (~> 5.2) 408 | turbolinks-source (5.2.0) 409 | tzinfo (1.2.5) 410 | thread_safe (~> 0.1) 411 | uglifier (4.1.20) 412 | execjs (>= 0.3.0, < 3) 413 | unicode-display_width (1.6.0) 414 | unicode_utils (1.4.0) 415 | uniform_notifier (1.12.1) 416 | vcr (5.0.0) 417 | warden (1.2.8) 418 | rack (>= 2.0.6) 419 | web-console (3.7.0) 420 | actionview (>= 5.0) 421 | activemodel (>= 5.0) 422 | bindex (>= 0.4.0) 423 | railties (>= 5.0) 424 | webmock (3.6.0) 425 | addressable (>= 2.3.6) 426 | crack (>= 0.3.2) 427 | hashdiff (>= 0.4.0, < 2.0.0) 428 | websocket-driver (0.7.1) 429 | websocket-extensions (>= 0.1.0) 430 | websocket-extensions (0.1.4) 431 | wicked_pdf (1.4.0) 432 | activesupport 433 | wkhtmltopdf-binary (0.12.4) 434 | xpath (3.2.0) 435 | nokogiri (~> 1.8) 436 | 437 | PLATFORMS 438 | ruby 439 | 440 | DEPENDENCIES 441 | aasm 442 | annotate 443 | bootsnap (>= 1.1.0) 444 | bootstrap (~> 4.3.1) 445 | bullet 446 | byebug 447 | capybara (>= 2.15) 448 | carrierwave (~> 1.0) 449 | chromedriver-helper 450 | coffee-rails (~> 4.2) 451 | country_select 452 | devise 453 | dotenv-rails 454 | draper 455 | factory_bot_rails 456 | faker 457 | fog-aws 458 | fuubar 459 | jquery-rails 460 | kaminari 461 | letter_opener 462 | listen (>= 3.0.5, < 3.2) 463 | mini_magick 464 | pg 465 | premailer-rails 466 | pry-rails 467 | puma (~> 3.11) 468 | punchbox! 469 | pundit 470 | rack-mini-profiler 471 | rails (~> 5.2.3) 472 | rails-controller-testing 473 | rspec-rails (~> 3.8) 474 | rubocop-rails 475 | sass-rails (~> 5.0) 476 | selenium-webdriver 477 | sentry-raven 478 | shoulda-matchers 479 | sidekiq 480 | simple_form 481 | simplecov 482 | slim 483 | spring 484 | spring-watcher-listen (~> 2.0.0) 485 | sprockets (>= 3.0.0) 486 | sprockets-es6 487 | turbolinks (~> 5) 488 | tzinfo-data 489 | uglifier (>= 1.3.0) 490 | value_objects! 491 | vcr 492 | web-console (>= 3.3.0) 493 | webmock 494 | wicked_pdf 495 | wkhtmltopdf-binary 496 | 497 | RUBY VERSION 498 | ruby 2.6.3p62 499 | 500 | BUNDLED WITH 501 | 2.0.2 502 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Maximilian Stoiber 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 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec puma -C config/puma.rb 2 | worker: bundle exec sidekiq -c 2 -q default -q mailers 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GO Rails Template 2 | 3 | A template to build large scale web applications in Ruby On Rails. Focus on extending, performance and best practices by applying patterns: Service Objects, Form Objects, Query Objects, Calculation Objects, Value Objects, Policy Objects, Decorators, etc. 4 | 5 |

6 | react boilerplate banner 7 |

8 | 9 |
10 | 11 |

12 | Created by Ben Tran with ❤️ 13 |
14 | 15 | ## General Information 16 | 17 | - Ruby version: `ruby 2.6.3` 18 | - Rails version: `rails 5.2.3` 19 | - Database: `postgresql` 20 | 21 | ## Features 22 | 23 | - Rubocop config 24 | - Codeclimate config 25 | - Basic [devise](https://github.com/plataformatec/devise) authentication setup 26 | - View template render by [slim](http://slim-lang.com/) 27 | - Support Javascript ES6 in Assets Pipeline 28 | - Page-specific Javascript with [punchbox](https://github.com/GoldenOwlAsia/punchbox) 29 | - Easier form helpers with [simple_form](https://github.com/plataformatec/simple_form) 30 | - Pagination with [kaminari](https://github.com/kaminari/kaminari) 31 | - PDF generator with [wicked_pdf](https://github.com/mileszs/wicked_pdf) 32 | - Email preview in the browser instead of sending with [letter_opener](https://github.com/ryanb/letter_opener) 33 | - CSS styled email without the hassle with [premailer-rails](https://github.com/fphilipe/premailer-rails) 34 | - Annotate rails classes with schema and routes info [annotate_models](https://github.com/ctran/annotate_models) 35 | - Performance checking in development environment with [bullet](https://github.com/flyerhzm/bullet) and [rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler) 36 | - Environment variables loading with [dotenv](https://github.com/bkeepers/dotenv) 37 | - [Sidekiq](https://github.com/mperham/sidekiq) default for Active Job queue adapter 38 | - [Carrierwave](https://github.com/carrierwaveuploader/carrierwave) file upload (development, test evironments: local file storage - staging, production: AWS S3 fog storage) 39 | - Full settings for testing application: [rspec](https://rspec.info/), [factory_bot_rails](https://github.com/thoughtbot/factory_bot_rails), [faker](https://github.com/stympy/faker), [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers), [webmock](https://github.com/bblimke/webmock), [vcr](https://github.com/vcr/vcr) 40 | - Error tracking config in production with Sentry 41 | - Base class init for common patterns in rails application: Service Objects, Form Objects, Query Objects, Calculation Objects, Value Objects, Policy Objects, Decorators, etc 42 | 43 | ## Quick Start 44 | 45 | 1. Make sure that you have installed ruby, rails, redis and postgresql. Read [this guide](https://gorails.com/setup) to install if you don't have. 46 | 2. Clone this repo using `git clone --depth=1 git@github.com:GoldenOwlAsia/go_rails_template.git ` 47 | 3. Move to the appropriate directory: `cd ` 48 | 4. Install correct ruby version for our project. If you have `rbenv`, use these commands: 49 | 50 | ``` 51 | rbenv install 2.6.3 52 | rbenv local 2.6.3 53 | ``` 54 | 55 | 5. Install bundler: `gem install bundler` 56 | 6. Install gems: `bundle install` 57 | 7. Add database config: create `config/database.yml` file (refer from `config/database.yml.example`) 58 | 8. Add environment variables: create `.env` file (refer from `.env.example`) 59 | 9. Database setup: `bundle exec rake db:setup` 60 | 10. Run sidekiq (make sure redis service is running): `bundle exec sidekiq` 61 | 11. Start server: `rails s` 62 | 12. Visit `http://localhost:3000` and start your development 63 | 64 | ## Testing 65 | 66 | 1. Start to run your specs by: `bundle exec rspec` 67 | 2. See coverage by open `coverage/index.html` in web browser 68 | 69 | ## Main Structure 70 | 71 | ``` 72 | app 73 | ├── assets 74 | │   ├── javascripts 75 | │   │   ├── application.js.es6 76 | │   │   ├── cable.js.es6 77 | │   │   ├── channels 78 | │   │   └── views 79 | │   │   └── home.js.es6 80 | │   └── stylesheets 81 | │   └── views 82 | │   │   ├── home.scss 83 | │   │   └── variables.scss 84 | │   ├── common 85 | │   │   ├── fonts.scss 86 | │   │   └── variables.scss 87 | │   └── application.scss 88 | ├── calculations 89 | │   └── application_calculation.rb 90 | ├── controllers 91 | │   ├── concerns 92 | │   ├── application_controller.rb 93 | │   └── home_controller.rb 94 | ├── decorators 95 | │   ├── application_decorator.rb 96 | │   └── paginating_decorator.rb 97 | ├── forms 98 | │   └── application_form.rb 99 | ├── helpers 100 | │   └── application_helper.rb 101 | ├── jobs 102 | │   └── application_job.rb 103 | ├── mailers 104 | │   └── application_mailer.rb 105 | ├── models 106 | │   ├── concerns 107 | │   └── application_record.rb 108 | ├── policies 109 | │   └── application_policy.rb 110 | ├── queries 111 | │   └── application_query.rb 112 | ├── services 113 | │   └── application_service.rb 114 | ├── value_objects 115 | │   └── application_value_object.rb 116 | └── views 117 | ├── devise 118 | ├── home 119 | ├── layouts 120 | └── shared 121 | ``` 122 | 123 | ## Common Patterns 124 | 125 | In software engineering, a software design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Design patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system. 126 | 127 | #### Service Objects 128 | 129 | Service objects are commonly used to mitigate problems with model callbacks that interact with external classes ([read more](https://samuelmullen.com/2013/05/the-problem-with-rails-callbacks/)). Service objects are also useful for handling processes involving multiple steps. E.g. a controller that performs more than one operation on its subject (usually a model instance) is a possible candidate for Extract ServiceObject (or Extract FormObject) refactoring. In many cases service object can be used as scaffolding for [replace method with object refactoring](https://sourcemaking.com/refactoring/replace-method-with-method-object). Some more information on using services can be found in [this article](https://medium.com/selleo/essential-rubyonrails-patterns-part-1-service-objects-1af9f9573ca1). 130 | 131 | Defining: 132 | 133 | ``` 134 | class ActivateUserService < ApplicationService 135 | attr_reader :user 136 | 137 | def initialize(user) 138 | @user = user 139 | end 140 | 141 | def call 142 | user.activate! 143 | NotificationsMailer.user_activation_notification(user).deliver_later 144 | user 145 | end 146 | end 147 | ``` 148 | 149 | Usage: 150 | 151 | ``` 152 | user = User.find(params[:id]) 153 | ActivateUserService.call(user) 154 | ``` 155 | 156 | #### Form Objects 157 | 158 | Form objects, just like service objects, are commonly used to mitigate problems with model callbacks that interact with external classes ([read more](https://samuelmullen.com/2013/05/the-problem-with-rails-callbacks/)). Form objects can be used as wrappers for virtual (with no model representation) or composite (saving multiple models at once) resources. In the latter case this may act as replacement for ActiveRecord::NestedAttributes. In some cases FormObject can be used as scaffolding for [replace method with object refactoring](https://sourcemaking.com/refactoring/replace-method-with-method-object). Some more information on using form objects can be found [in this article](https://medium.com/selleo/essential-rubyonrails-patterns-form-objects-b199aada6ec9). 159 | 160 | Defining: 161 | 162 | ``` 163 | class UserRegistrationForm < ApplicationForm 164 | attr_accessor :user, :terms_of_service 165 | 166 | delegate :attributes=, to: :user, prefix: true 167 | 168 | validates :terms_of_service, acceptance: true 169 | 170 | def initialize(user, params = {}) 171 | @user = user 172 | super(params) 173 | end 174 | 175 | def submit 176 | return false if invalid? 177 | user.save 178 | end 179 | 180 | def persisted? 181 | user.persisted? 182 | end 183 | end 184 | ``` 185 | 186 | Usage: 187 | 188 | ``` 189 | user = User.new 190 | form = UserRegistrationForm.new(user, permitted_params) 191 | form.submit 192 | ``` 193 | 194 | #### Query Objects 195 | 196 | One should consider using query objects pattern when in need to perform complex querying on active record relation. Usually one should avoid using scopes for such purpose. As a rule of thumb, if scope interacts with more than one column and/or joins in other tables, it should be moved to query object. Also whenever a chain of scopes is to be used, one should consider using query object too. Some more information on using query objects can be found in [this article](https://medium.com/selleo/essential-rubyonrails-patterns-part-2-query-objects-4b253f4f4539). 197 | 198 | Defining: 199 | ``` 200 | class RecentlyActivatedUsersQuery < ApplicationQuery 201 | query_on 'User' 202 | 203 | def call 204 | relation.active.where(activated_at: date_range) 205 | end 206 | 207 | private 208 | 209 | def date_range 210 | options.fetch(:date_range, default_date_range) 211 | end 212 | 213 | def default_date_range 214 | Date.yesterday.beginning_of_day..Date.current.end_of_day 215 | end 216 | end 217 | ``` 218 | 219 | Usage: 220 | ``` 221 | RecentlyActivatedUsersQuery.call 222 | RecentlyActivatedUsersQuery.call(date_range: Date.today.beginning_of_day..Date.today.end_of_day) 223 | RecentlyActivatedUsersQuery.call(User.male, date_range: Date.today.beginning_of_day..Date.today.end_of_day) 224 | ``` 225 | 226 | #### Calculation Objects 227 | 228 | Calculation objects provide a place to calculate simple values (i.e. numeric, arrays, hashes), especially when calculations require interacting with multiple classes, and thus do not fit into any particular one. 229 | 230 | Defining: 231 | ``` 232 | class AverageHotelDailyRevenueCalculation < ApplicationCalculation 233 | def call 234 | reservations.sum(:price) / number_of_days_in_year 235 | end 236 | 237 | private 238 | 239 | def reservations 240 | Reservation.where( 241 | date: (beginning_of_year..end_of_year), 242 | hotel_id: options[:hotel_id] 243 | ) 244 | end 245 | 246 | def number_of_days_in_year 247 | end_of_year.yday 248 | end 249 | 250 | def year 251 | options[:year] || Date.current.year 252 | end 253 | 254 | def beginning_of_year 255 | Date.new(year).beginning_of_year 256 | end 257 | 258 | def end_of_year 259 | Date.new(year).end_of_year 260 | end 261 | end 262 | ``` 263 | 264 | Usage: 265 | ``` 266 | hotel = current_user.owned_hotel 267 | AverageHotelDailyRevenueCalculation.call(hotel_id: hotel.id) 268 | AverageHotelDailyRevenueCalculation.call(hotel_id: hotel.id, year: 2018) 269 | ``` 270 | 271 | #### Value Objects 272 | 273 | The Value Object design pattern encourages simple, small objects (which usually just contain given values), and lets you compare these objects according to a given logic or simply based on specific attributes (and not on their identity). 274 | 275 | Read more at [value_objects document](https://github.com/GoldenOwlAsia/value_objects). 276 | 277 | Defining: 278 | ``` 279 | class AddressValueObject < ApplicationValueObject 280 | attr_accessor :street, :postcode, :city 281 | 282 | validates :postcode, presence: true 283 | validates :city, presence: true 284 | end 285 | ``` 286 | 287 | Usage: 288 | 289 | ``` 290 | address = AddressValueObject.new(street: '123 Big Street', city: 'Metropolis') 291 | address.valid? # => false 292 | address.errors.to_h # => {:postcode=>"can't be blank"} 293 | address.postcode = '12345' # => "12345" 294 | address.valid? # => true 295 | address.errors.to_h # => {} 296 | ``` 297 | 298 | Usage in Active Record: 299 | ``` 300 | class User < ActiveRecord::Base 301 | include ValueObjects::ActiveRecord 302 | 303 | value_object :company_addresses, AddressValueObject::Collection 304 | value_object :home_address, AddressValueObject 305 | end 306 | ``` 307 | 308 | #### Policy Objects 309 | 310 | The Policy Objects design pattern is similar to Service Objects, but is responsible for read operations while Service Objects are responsible for write operations. Policy Objects encapsulate complex business rules and can easily be replaced by other Policy Objects with different rules. For example, we can check if a guest user is able to retrieve certain resources using a guest Policy Object. If the user is an admin, we can easily change this guest Policy Object to an admin Policy Object that contains admin rules. 311 | 312 | Read more at [pundit document](https://github.com/varvet/pundit). 313 | 314 | Defining: 315 | ``` 316 | class ArticlePolicy < ApplicationPolicy 317 | def create? 318 | user.admin? 319 | end 320 | 321 | def update? 322 | user.admin? && !record.published? 323 | end 324 | end 325 | ``` 326 | 327 | Usage: 328 | ``` 329 | @article = Article.find(params[:id]) 330 | authorize @article, :update? 331 | @article.update(article_params) 332 | ``` 333 | 334 | 335 | #### Decorators 336 | 337 | The Decorator Pattern allows us to add any kind of auxiliary behavior to individual objects without affecting other objects of the same class. This design pattern is widely used to divide functionality across different classes, and is a good alternative to subclasses for adhering to the Single Responsibility Principle. 338 | 339 | Read more at [draper document](https://github.com/drapergem/draper). 340 | 341 | Define: 342 | ``` 343 | class ArticleDecorator < Draper::Decorator 344 | delegate_all 345 | 346 | def publication_status 347 | if published? 348 | "Published at #{published_at}" 349 | else 350 | "Unpublished" 351 | end 352 | end 353 | 354 | def published_at 355 | object.published_at.strftime("%A, %B %e") 356 | end 357 | end 358 | ``` 359 | 360 | Usage: 361 | ``` 362 | article = Article.find(params[:id]).decorate 363 | article.publication_status 364 | article.published_at 365 | ``` 366 | 367 | ## Deployment 368 | 369 | For deployment, you can use AWS Elastic Beanstalk Service (AWS EB) which have most interesting parts from my experiences: 370 | - Handles the deployment process, you just need to bundle the app and send to EB then you’re free to do others thing. Don’t need to wait for processing tasks via SSH connection, as result in speed up your development. 371 | - Handles load balancing, auto-scaling by triggered to the app health monitoring. You can easy to setting up from EB management console. 372 | - And finally, no additional charge for using EB. If you are using the same resources (EC2, CloudFront, S3, RDS, Route 53, ElasticCache,…) then EB won’t add more charges to your bill. 373 | 374 | I have written [a complete guide to deploy rails application to AWS EB](https://github.com/tranquangvu/dev-notes/tree/master/deploys-rails-to-awseb). Please take a look on it. 375 | 376 | ## License 377 | 378 | Licensed under the MIT license, see the separate LICENSE.md file. 379 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/images/rails.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | rails-logo 6 | 7 | 10 | 12 | 15 | 16 | 18 | 20 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/assets/images/welcome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/app/assets/images/welcome.png -------------------------------------------------------------------------------- /app/assets/javascripts/application.js.es6: -------------------------------------------------------------------------------- 1 | //= require rails-ujs 2 | //= require activestorage 3 | //= require turbolinks 4 | //= require jquery3 5 | //= require popper 6 | //= require bootstrap-sprockets 7 | //= require punchbox 8 | 9 | //= require ./views/home 10 | -------------------------------------------------------------------------------- /app/assets/javascripts/cable.js.es6: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/app/assets/javascripts/channels/.keep -------------------------------------------------------------------------------- /app/assets/javascripts/views/home.js.es6: -------------------------------------------------------------------------------- 1 | class Home { 2 | controller() { 3 | console.log('Log from every action in home controller'); 4 | } 5 | 6 | index() { 7 | console.log('Log from home#index'); 8 | } 9 | } 10 | 11 | Punchbox.on('Home', Home); 12 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | @import 'bootstrap'; 2 | 3 | @import './common/**/*'; 4 | @import './views/layout'; 5 | @import './views/home'; 6 | -------------------------------------------------------------------------------- /app/assets/stylesheets/common/fonts.scss: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Montserrat:300,300i,400,400i,500,500i,600,600i,700,700i&display=swap'); 2 | -------------------------------------------------------------------------------- /app/assets/stylesheets/common/variables.scss: -------------------------------------------------------------------------------- 1 | // Colors 2 | $white: #FFFFFF; 3 | $black: #000000; 4 | 5 | // Fonts 6 | $montserrat: 'Montserrat', sans-serif; 7 | -------------------------------------------------------------------------------- /app/assets/stylesheets/views/home.scss: -------------------------------------------------------------------------------- 1 | body[data-punchbox-controller='home'][data-punchbox-action='index'] { 2 | section { 3 | text-align: center; 4 | max-width: 960px; 5 | margin: 0 auto; 6 | } 7 | 8 | h1 { 9 | font-weight: 300; 10 | margin: 2.5rem auto; 11 | } 12 | 13 | .logo { 14 | margin: 2rem auto 1rem; 15 | display: block; 16 | 17 | img { 18 | width: 130px; 19 | height: 46px; 20 | } 21 | } 22 | 23 | img.welcome { 24 | width: 600px; 25 | max-width: 100%; 26 | } 27 | 28 | p.version { 29 | margin: 1.5rem auto; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/assets/stylesheets/views/layout.scss: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: $montserrat; 3 | font-size: 1rem; 4 | } 5 | -------------------------------------------------------------------------------- /app/calculations/application_calculation.rb: -------------------------------------------------------------------------------- 1 | class ApplicationCalculation 2 | attr_reader :options 3 | 4 | def self.call(*args) 5 | new(*args).call 6 | end 7 | 8 | def initialize(*args) 9 | @options = args.extract_options! 10 | end 11 | 12 | def call 13 | raise NotImplementedError, "You must define `call` as instance method in #{self.class.name} class." 14 | end 15 | 16 | # Usage: 17 | # 18 | # class AverageHotelDailyRevenueCalculation < ApplicationCalculation 19 | # def call 20 | # reservations.sum(:price) / number_of_days_in_year 21 | # end 22 | # 23 | # private 24 | # 25 | # def reservations 26 | # Reservation.where( 27 | # date: (beginning_of_year..end_of_year), 28 | # hotel_id: options[:hotel_id] 29 | # ) 30 | # end 31 | # 32 | # def number_of_days_in_year 33 | # end_of_year.yday 34 | # end 35 | # 36 | # def year 37 | # options[:year] || Date.current.year 38 | # end 39 | # 40 | # def beginning_of_year 41 | # Date.new(year).beginning_of_year 42 | # end 43 | # 44 | # def end_of_year 45 | # Date.new(year).end_of_year 46 | # end 47 | # end 48 | # 49 | # hotel = current_user.owned_hotel 50 | # AverageHotelDailyRevenueCalculation.call(hotel_id: hotel.id) 51 | # AverageHotelDailyRevenueCalculation.call(hotel_id: hotel.id, year: 2018) 52 | end 53 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /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 | include Pundit 3 | 4 | rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized 5 | 6 | private 7 | 8 | def user_not_authorized(exception) 9 | redirect_to user_not_authorized_path, alert: t("#{exception.policy.class.to_s.underscore.tr('/', '.')}.#{exception.query}", scope: 'pundit', default: :default) 10 | end 11 | 12 | def user_not_authorized_path 13 | root_path 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | def index; end 3 | end 4 | -------------------------------------------------------------------------------- /app/decorators/application_decorator.rb: -------------------------------------------------------------------------------- 1 | class ApplicationDecorator < Draper::Decorator 2 | end 3 | -------------------------------------------------------------------------------- /app/decorators/paginating_decorator.rb: -------------------------------------------------------------------------------- 1 | class PaginatingDecorator < Draper::CollectionDecorator 2 | delegate :current_page, :total_pages, :limit_value, :entry_name, :total_count, :offset_value, :last_page? 3 | end 4 | -------------------------------------------------------------------------------- /app/forms/application_form.rb: -------------------------------------------------------------------------------- 1 | class ApplicationForm 2 | include ActiveModel::Model 3 | 4 | class << self 5 | def i18n_scope 6 | :form 7 | end 8 | end 9 | 10 | def persisted? 11 | raise NotImplementedError, "You must define `persisted?` as instance method in #{self.class.name} class." 12 | end 13 | 14 | # Usage: 15 | # 16 | # class UserRegistrationForm < ApplicationForm 17 | # attr_accessor :user, :terms_of_service 18 | # 19 | # delegate :attributes=, to: :user, prefix: true 20 | # 21 | # validates :terms_of_service, acceptance: true 22 | # 23 | # def initialize(user, params = {}) 24 | # @user = user 25 | # super(params) 26 | # end 27 | # 28 | # def submit 29 | # return false if invalid? 30 | # user.save 31 | # end 32 | # 33 | # def persisted? 34 | # user.persisted? 35 | # end 36 | # end 37 | # 38 | # user = User.new 39 | # form = UserRegistrationForm.new(user, permitted_params) 40 | # form.submit 41 | end 42 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: users 4 | # 5 | # id :bigint not null, primary key 6 | # email :string default(""), not null 7 | # encrypted_password :string default(""), not null 8 | # remember_created_at :datetime 9 | # reset_password_sent_at :datetime 10 | # reset_password_token :string 11 | # created_at :datetime not null 12 | # updated_at :datetime not null 13 | # 14 | # Indexes 15 | # 16 | # index_users_on_email (email) UNIQUE 17 | # index_users_on_reset_password_token (reset_password_token) UNIQUE 18 | # 19 | 20 | class User < ApplicationRecord 21 | # Include default devise modules. Others available are: 22 | # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable 23 | devise :database_authenticatable, :registerable, 24 | :recoverable, :rememberable, :validatable 25 | end 26 | -------------------------------------------------------------------------------- /app/policies/application_policy.rb: -------------------------------------------------------------------------------- 1 | class ApplicationPolicy 2 | attr_reader :user, :record 3 | 4 | def initialize(user, record) 5 | @user = user 6 | @record = record 7 | end 8 | 9 | def index? 10 | false 11 | end 12 | 13 | def show? 14 | false 15 | end 16 | 17 | def create? 18 | false 19 | end 20 | 21 | def new? 22 | create? 23 | end 24 | 25 | def update? 26 | false 27 | end 28 | 29 | def edit? 30 | update? 31 | end 32 | 33 | def destroy? 34 | false 35 | end 36 | 37 | class Scope 38 | attr_reader :user, :scope 39 | 40 | def initialize(user, scope) 41 | @user = user 42 | @scope = scope 43 | end 44 | 45 | def resolve 46 | scope.all 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /app/queries/application_query.rb: -------------------------------------------------------------------------------- 1 | class ApplicationQuery 2 | attr_reader :relation, :options 3 | class_attribute :relation_class 4 | 5 | class << self 6 | def call(*args) 7 | new(*args).call 8 | end 9 | 10 | def query_on(object) 11 | raise StandardError, "#{name} class's query_on method require param as a model class name, can not be blank." if object.blank? 12 | 13 | self.relation_class = object.is_a?(String) ? object.constantize : object 14 | end 15 | 16 | def base_relation 17 | raise StandardError, "#{name} class require relation class defined. Use query_on method to define it." unless relation_class 18 | 19 | relation_class.all 20 | end 21 | end 22 | 23 | def initialize(*args) 24 | @options = args.extract_options! 25 | @relation = args.first || self.class.base_relation 26 | end 27 | 28 | def call 29 | raise NotImplementedError, "You must define `call` as instance method in #{self.class.name} class." 30 | end 31 | 32 | # Usage: 33 | # Inherited class should set relation class by call `query_on` method and 34 | # define `call` as instance method which returns ActiveRecord::Relation object 35 | # 36 | # class RecentlyActivatedUsersQuery < ApplicationQuery 37 | # query_on 'User' 38 | # 39 | # def call 40 | # relation.active.where(activated_at: date_range) 41 | # end 42 | # 43 | # private 44 | # 45 | # def date_range 46 | # options.fetch(:date_range, default_date_range) 47 | # end 48 | # 49 | # def default_date_range 50 | # Date.yesterday.beginning_of_day..Date.current.end_of_day 51 | # end 52 | # end 53 | # 54 | # RecentlyActivatedUsersQuery.call 55 | # RecentlyActivatedUsersQuery.call(date_range: Date.today.beginning_of_day..Date.today.end_of_day) 56 | # RecentlyActivatedUsersQuery.call(User.male, date_range: Date.today.beginning_of_day..Date.today.end_of_day) 57 | end 58 | -------------------------------------------------------------------------------- /app/services/application_service.rb: -------------------------------------------------------------------------------- 1 | class ApplicationService 2 | def self.call(*args) 3 | new(*args).call 4 | end 5 | 6 | def call 7 | raise NotImplementedError, "You must define `call` as instance method in #{self.class.name} class" 8 | end 9 | 10 | # Usage: 11 | # 12 | # class ActivateUserService < ApplicationService 13 | # attr_reader :user 14 | # 15 | # def initialize(user) 16 | # @user = user 17 | # end 18 | # 19 | # def call 20 | # user.activate! 21 | # NotificationsMailer.user_activation_notification(user).deliver_later 22 | # user 23 | # end 24 | # end 25 | # 26 | # user = User.find(1) 27 | # ActivateUserService.call(user) 28 | end 29 | -------------------------------------------------------------------------------- /app/uploaders/file_uploader.rb: -------------------------------------------------------------------------------- 1 | class FileUploader < CarrierWave::Uploader::Base 2 | # Include RMagick or MiniMagick support: 3 | # include CarrierWave::RMagick 4 | # include CarrierWave::MiniMagick 5 | 6 | # Choose what kind of storage to use for this uploader: 7 | # storage :file 8 | # storage :fog 9 | 10 | # Override the directory where uploaded files will be stored. 11 | # This is a sensible default for uploaders that are meant to be mounted: 12 | def store_dir 13 | "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" 14 | end 15 | 16 | # Provide a default URL as a default if there hasn't been a file uploaded: 17 | # def default_url(*args) 18 | # # For Rails 3.1+ asset pipeline compatibility: 19 | # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) 20 | # 21 | # "/images/fallback/" + [version_name, "default.png"].compact.join('_') 22 | # end 23 | 24 | # Process files as they are uploaded: 25 | # process scale: [200, 300] 26 | # 27 | # def scale(width, height) 28 | # # do something 29 | # end 30 | 31 | # Create different versions of your uploaded files: 32 | # version :thumb do 33 | # process resize_to_fit: [50, 50] 34 | # end 35 | 36 | # Add a white list of extensions which are allowed to be uploaded. 37 | # For images you might use something like this: 38 | # def extension_whitelist 39 | # %w(jpg jpeg gif png) 40 | # end 41 | 42 | # Override the filename of the uploaded files: 43 | # Avoid using model.id or version_name here, see uploader/store.rb for details. 44 | # def filename 45 | # "something.jpg" if original_filename 46 | # end 47 | end 48 | -------------------------------------------------------------------------------- /app/validators/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/app/validators/.keep -------------------------------------------------------------------------------- /app/value_objects/application_value_object.rb: -------------------------------------------------------------------------------- 1 | class ApplicationValueObject < ValueObjects::Base 2 | class Collection < Collection; end 3 | 4 | # Usage: 5 | # Read more at: https://github.com/GoldenOwlAsia/value_objects 6 | # 7 | # class AddressValueObject < ApplicationValueObject 8 | # attr_accessor :street, :postcode, :city 9 | # 10 | # validates :postcode, presence: true 11 | # validates :city, presence: true 12 | # end 13 | # 14 | # address = AddressValueObject.new(street: '123 Big Street', city: 'Metropolis') 15 | # address.valid? # => false 16 | # address.errors.to_h # => {:postcode=>"can't be blank"} 17 | # address.postcode = '12345' # => "12345" 18 | # address.valid? # => true 19 | # address.errors.to_h # => {} 20 | # 21 | # In ActiveRecord 22 | # class User < ActiveRecord::Base 23 | # include ValueObjects::ActiveRecord 24 | # 25 | # value_object :company_addresses, AddressValueObject::Collection 26 | # value_object :home_address, AddressValueObject 27 | # end 28 | end 29 | -------------------------------------------------------------------------------- /app/views/devise/confirmations/new.html.slim: -------------------------------------------------------------------------------- 1 | h2 2 | | Resend confirmation instructions 3 | = simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| 4 | = f.error_notification 5 | = f.full_error :confirmation_token 6 | .form-inputs 7 | = f.input :email, required: true, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email), input_html: { autocomplete: 'email' } 8 | .form-actions 9 | = f.button :submit, 'Resend confirmation instructions' 10 | = render 'devise/shared/links' 11 | -------------------------------------------------------------------------------- /app/views/devise/mailer/confirmation_instructions.html.slim: -------------------------------------------------------------------------------- 1 | p 2 | | Welcome 3 | = @email 4 | | ! 5 | p 6 | | You can confirm your account email through the link below: 7 | p 8 | = link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) 9 | -------------------------------------------------------------------------------- /app/views/devise/mailer/email_changed.html.slim: -------------------------------------------------------------------------------- 1 | p 2 | | Hello 3 | = @email 4 | | ! 5 | - if @resource.try(:unconfirmed_email?) 6 | p 7 | | We're contacting you to notify you that your email is being changed to 8 | = @resource.unconfirmed_email 9 | | . 10 | - else 11 | p 12 | | We're contacting you to notify you that your email has been changed to 13 | = @resource.email 14 | | . 15 | -------------------------------------------------------------------------------- /app/views/devise/mailer/password_change.html.slim: -------------------------------------------------------------------------------- 1 | p 2 | | Hello 3 | = @resource.email 4 | | ! 5 | p 6 | | We're contacting you to notify you that your password has been changed. 7 | -------------------------------------------------------------------------------- /app/views/devise/mailer/reset_password_instructions.html.slim: -------------------------------------------------------------------------------- 1 | p 2 | | Hello 3 | = @resource.email 4 | | ! 5 | p 6 | | Someone has requested a link to change your password. You can do this through the link below. 7 | p 8 | = link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) 9 | p 10 | | If you didn't request this, please ignore this email. 11 | p 12 | | Your password won't change until you access the link above and create a new one. 13 | -------------------------------------------------------------------------------- /app/views/devise/mailer/unlock_instructions.html.slim: -------------------------------------------------------------------------------- 1 | p 2 | | Hello 3 | = @resource.email 4 | | ! 5 | p 6 | | Your account has been locked due to an excessive number of unsuccessful sign in attempts. 7 | p 8 | | Click the link below to unlock your account: 9 | p 10 | = link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) 11 | -------------------------------------------------------------------------------- /app/views/devise/passwords/edit.html.slim: -------------------------------------------------------------------------------- 1 | h2 2 | | Change your password 3 | = simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| 4 | = f.error_notification 5 | = f.input :reset_password_token, as: :hidden 6 | = f.full_error :reset_password_token 7 | .form-inputs 8 | = f.input :password, label: 'New password', required: true, autofocus: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length), input_html: { autocomplete: 'new-password' } 9 | = f.input :password_confirmation, label: 'Confirm your new password', required: true 10 | .form-actions 11 | = f.button :submit, 'Change my password' 12 | = render 'devise/shared/links' 13 | -------------------------------------------------------------------------------- /app/views/devise/passwords/new.html.slim: -------------------------------------------------------------------------------- 1 | h2 2 | | Forgot your password? 3 | = simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| 4 | = f.error_notification 5 | .form-inputs 6 | = f.input :email, required: true, autofocus: true, input_html: { autocomplete: 'email' } 7 | .form-actions 8 | = f.button :submit, 'Send me reset password instructions' 9 | = render 'devise/shared/links' 10 | -------------------------------------------------------------------------------- /app/views/devise/registrations/edit.html.slim: -------------------------------------------------------------------------------- 1 | h2 2 | | Edit 3 | = resource_name.to_s.humanize 4 | = simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| 5 | = f.error_notification 6 | .form-inputs 7 | = f.input :email, required: true, autofocus: true 8 | - if devise_mapping.confirmable? && resource.pending_reconfirmation? 9 | p 10 | | Currently waiting confirmation for: 11 | = resource.unconfirmed_email 12 | = f.input :password, hint: "leave it blank if you don't want to change it", required: false, input_html: { autocomplete: 'new-password' } 13 | = f.input :password_confirmation, required: false, input_html: { autocomplete: 'new-password' } 14 | = f.input :current_password, hint: 'we need your current password to confirm your changes', required: true, input_html: { autocomplete: 'current-password' } 15 | .form-actions 16 | = f.button :submit, 'Update' 17 | h3 18 | | Cancel my account 19 | p 20 | | Unhappy? 21 | = link_to 'Cancel my account', registration_path(resource_name), data: { confirm: 'Are you sure?' }, method: :delete 22 | = link_to 'Back', :back 23 | -------------------------------------------------------------------------------- /app/views/devise/registrations/new.html.slim: -------------------------------------------------------------------------------- 1 | h2 2 | | Sign up 3 | = simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| 4 | = f.error_notification 5 | .form-inputs 6 | = f.input :email, required: true, autofocus: true, input_html: { autocomplete: 'email' } 7 | = f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length), input_html: { autocomplete: "new-password" } 8 | = f.input :password_confirmation, required: true, input_html: { autocomplete: 'new-password' } 9 | .form-actions 10 | = f.button :submit, 'Sign up' 11 | = render 'devise/shared/links' 12 | -------------------------------------------------------------------------------- /app/views/devise/sessions/new.html.slim: -------------------------------------------------------------------------------- 1 | h2 2 | | Log in 3 | = simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| 4 | .form-inputs 5 | = f.input :email, required: false, autofocus: true, input_html: { autocomplete: 'email' } 6 | = f.input :password, required: false, input_html: { autocomplete: 'current-password' } 7 | = f.input :remember_me, as: :boolean if devise_mapping.rememberable? 8 | .form-actions 9 | = f.button :submit, 'Log in' 10 | = render 'devise/shared/links' 11 | -------------------------------------------------------------------------------- /app/views/devise/shared/_error_messages.html.slim: -------------------------------------------------------------------------------- 1 | - if resource.errors.any? 2 | #error_explanation 3 | h2 4 | = I18n.t('errors.messages.not_saved', count: resource.errors.count, resource: resource.class.model_name.human.downcase) 5 | ul 6 | - resource.errors.full_messages.each do |message| 7 | li 8 | = message 9 | -------------------------------------------------------------------------------- /app/views/devise/shared/_links.html.slim: -------------------------------------------------------------------------------- 1 | - if controller_name != 'sessions' 2 | = link_to 'Log in', new_session_path(resource_name) 3 | br 4 | - if devise_mapping.registerable? && controller_name != 'registrations' 5 | = link_to 'Sign up', new_registration_path(resource_name) 6 | br 7 | - if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' 8 | = link_to 'Forgot your password?', new_password_path(resource_name) 9 | br 10 | - if devise_mapping.confirmable? && controller_name != 'confirmations' 11 | = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) 12 | br 13 | - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' 14 | = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) 15 | br 16 | - if devise_mapping.omniauthable? 17 | - resource_class.omniauth_providers.each do |provider| 18 | = link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) 19 | br 20 | -------------------------------------------------------------------------------- /app/views/devise/unlocks/new.html.slim: -------------------------------------------------------------------------------- 1 | h2 2 | | Resend unlock instructions 3 | = simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| 4 | = f.error_notification 5 | = f.full_error :unlock_token 6 | .form-inputs 7 | = f.input :email, required: true, autofocus: true, input_html: { autocomplete: 'email' } 8 | .form-actions 9 | = f.button :submit, 'Resend unlock instructions' 10 | = render 'devise/shared/links' 11 | -------------------------------------------------------------------------------- /app/views/home/index.html.slim: -------------------------------------------------------------------------------- 1 | section 2 | = link_to 'https://rubyonrails.org', class: 'logo' 3 | = image_tag 'rails.svg', alt: 'Ruby On Rails' 4 | h1 Yay! You’re on Rails! 5 | = image_tag 'welcome.png', alt: 'Welcome', class: 'welcome' 6 | p.version 7 | | rails_#{Rails::VERSION::STRING} - ruby_#{RUBY_VERSION} 8 | br 9 | | Template created by  10 | = link_to 'GoldenOwl', 'https://www.goldenowl.asia/' 11 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.slim: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | title 5 | | Golden Owl Consulting | www.goldenowl.asia 6 | = csrf_meta_tags 7 | = csp_meta_tag 8 | = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' 9 | = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' 10 | body *punchbox_data 11 | = render 'shared/layouts/flash' 12 | = yield 13 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.slim: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | meta[http-equiv="Content-Type" content="text/html; charset=utf-8"] 5 | style 6 | | /* Email styles need to be inline */ 7 | body 8 | = yield 9 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.slim: -------------------------------------------------------------------------------- 1 | = yield 2 | -------------------------------------------------------------------------------- /app/views/shared/layouts/_flash.html.slim: -------------------------------------------------------------------------------- 1 | - flash.each do |name, msg| 2 | = content_tag :div, msg, class: 'alert' 3 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../config/application', __dir__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a starting point to setup your application. 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 | # Install JavaScript dependencies if using Yarn 21 | # system('bin/yarn') 22 | 23 | # puts "\n== Copying sample files ==" 24 | # unless File.exist?('config/database.yml') 25 | # cp 'config/database.yml.sample', 'config/database.yml' 26 | # end 27 | 28 | puts "\n== Preparing database ==" 29 | system! 'bin/rails db:setup' 30 | 31 | puts "\n== Removing old logs and tempfiles ==" 32 | system! 'bin/rails log:clear tmp:clear' 33 | 34 | puts "\n== Restarting application server ==" 35 | system! 'bin/rails restart' 36 | end 37 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a way to update your development environment automatically. 14 | # Add necessary update steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies if using Yarn 21 | # system('bin/yarn') 22 | 23 | puts "\n== Updating database ==" 24 | system! 'bin/rails db:migrate' 25 | 26 | puts "\n== Removing old logs and tempfiles ==" 27 | system! 'bin/rails log:clear tmp:clear' 28 | 29 | puts "\n== Restarting application server ==" 30 | system! 'bin/rails restart' 31 | end 32 | -------------------------------------------------------------------------------- /bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_ROOT = File.expand_path('..', __dir__) 3 | Dir.chdir(APP_ROOT) do 4 | begin 5 | exec "yarnpkg", *ARGV 6 | rescue Errno::ENOENT 7 | $stderr.puts "Yarn executable was not detected in the system." 8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" 9 | exit 1 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | require 'sprockets/es6' 5 | 6 | # Require the gems listed in Gemfile, including any gems 7 | # you've limited to :test, :development, or :production. 8 | Bundler.require(*Rails.groups) 9 | 10 | module GoRails 11 | class Application < Rails::Application 12 | # Initialize configuration defaults for originally generated Rails version. 13 | config.load_defaults 5.2 14 | 15 | # Settings in config/environments/* take precedence over those specified here. 16 | # Application configuration can go into files in config/initializers 17 | # -- all .rb files in that directory are automatically loaded after loading 18 | # the framework and any gems in your application. 19 | 20 | # Set Active Job default queue to use sidekiq 21 | config.active_job.queue_adapter = :sidekiq 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /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 | require 'bootsnap/setup' # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: go_rails_template_production 11 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | oPpw+ESZr3AoBNIF1ThXKxrXNNfJi0v5QlCT34TazuT8nBtq4PiatyrcQ+N8Q29mIov2X+UrIpasBqT2QAtVRCgR4ovxtkYuMwbAIa+fomDjYgR5sudzUd4kxcO2Lx6vR4h+3z45J6mO2wsTjCBXVpx9c9h0FxPmGUADRkE3s/V8d7+wfEkbElFaYhc/UFwt+XJlHpDQtcSTJspeg2i5CJzh2ff5V+fd7MOWnU+x2DZIo2nvvVLQ72AaWZ6gses+OEPOKomEYCIUK2PKVuGNEHtxTAnkQwcsvUBkuFxdUuAvntQ2TC71c+Blh0QjNTWrxo97Ex0qHIZqWvS0L9WDC/9Zi/01Zd+R8KL8XY+U51CHwA3Zs7+8zUfIzW8k7ZJrubleucz5N0rZ1/YQORCVB5EKt94qsSqNncuH--4PKP4mfph7MOktmq--BmOMlmy+2pgFES9mJHcz7Q== -------------------------------------------------------------------------------- /config/database.yml.sample: -------------------------------------------------------------------------------- 1 | default: &default 2 | adapter: postgresql 3 | encoding: unicode 4 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 5 | timeout: 5000 6 | 7 | development: 8 | <<: *default 9 | database: go_rails_template_development 10 | 11 | test: 12 | <<: *default 13 | database: go_rails_template_test 14 | 15 | production: 16 | <<: *default 17 | database: <%= ENV['RDS_DB_NAME'] %> 18 | username: <%= ENV['RDS_USERNAME'] %> 19 | password: <%= ENV['RDS_PASSWORD'] %> 20 | host: <%= ENV['RDS_HOSTNAME'] %> 21 | port: <%= ENV['RDS_PORT'] %> 22 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /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 | 20 | config.cache_store = :memory_store 21 | config.public_file_server.headers = { 22 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 23 | } 24 | else 25 | config.action_controller.perform_caching = false 26 | 27 | config.cache_store = :null_store 28 | end 29 | 30 | # Store uploaded files on the local file system (see config/storage.yml for options) 31 | config.active_storage.service = :local 32 | 33 | # Don't care if the mailer can't send. 34 | config.action_mailer.raise_delivery_errors = true 35 | 36 | config.action_mailer.perform_caching = false 37 | 38 | config.action_mailer.default_url_options = { host: ENV['HOST'] } 39 | 40 | # Print deprecation notices to the Rails logger. 41 | config.active_support.deprecation = :log 42 | 43 | # Raise an error on page load if there are pending migrations. 44 | config.active_record.migration_error = :page_load 45 | 46 | # Highlight code that triggered database queries in logs. 47 | config.active_record.verbose_query_logs = true 48 | 49 | # Debug mode disables concatenation and preprocessing of assets. 50 | # This option may cause significant delays in view rendering with a large 51 | # number of complex assets. 52 | config.assets.debug = true 53 | 54 | # Suppress logger output for asset requests. 55 | config.assets.quiet = true 56 | 57 | # Raises error for missing translations 58 | # config.action_view.raise_on_missing_translations = true 59 | 60 | # Use an evented file watcher to asynchronously detect changes in source code, 61 | # routes, locales, etc. This feature depends on the listen gem. 62 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 63 | 64 | # Letter Opener settings 65 | config.action_mailer.delivery_method = :letter_opener 66 | config.action_mailer.perform_deliveries = true 67 | 68 | # Bullet settings 69 | config.after_initialize do 70 | Bullet.enable = true 71 | Bullet.alert = true 72 | Bullet.bullet_logger = true 73 | Bullet.console = true 74 | Bullet.rails_logger = true 75 | end 76 | end 77 | -------------------------------------------------------------------------------- /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 JavaScripts and CSS. 26 | config.assets.js_compressor = Uglifier.new(harmony: true) 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 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 33 | 34 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 35 | # config.action_controller.asset_host = 'http://assets.example.com' 36 | 37 | # Specifies the header that your server uses for sending files. 38 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 39 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 40 | 41 | # Store uploaded files on the local file system (see config/storage.yml for options) 42 | config.active_storage.service = :local 43 | 44 | # Mount Action Cable outside main process or domain 45 | # config.action_cable.mount_path = nil 46 | # config.action_cable.url = 'wss://example.com/cable' 47 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 48 | 49 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 50 | # config.force_ssl = true 51 | 52 | # Use the lowest log level to ensure availability of diagnostic information 53 | # when problems arise. 54 | config.log_level = :debug 55 | 56 | # Prepend all log lines with the following tags. 57 | config.log_tags = [ :request_id ] 58 | 59 | # Use a different cache store in production. 60 | # config.cache_store = :mem_cache_store 61 | 62 | # Use a real queuing backend for Active Job (and separate queues per environment) 63 | # config.active_job.queue_adapter = :resque 64 | # config.active_job.queue_name_prefix = "go_rails_template_#{Rails.env}" 65 | 66 | config.action_mailer.perform_caching = false 67 | 68 | config.action_mailer.default_url_options = { host: ENV['HOST'] } 69 | 70 | # Ignore bad email addresses and do not raise email delivery errors. 71 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 72 | # config.action_mailer.raise_delivery_errors = false 73 | 74 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 75 | # the I18n.default_locale when a translation cannot be found). 76 | config.i18n.fallbacks = true 77 | 78 | # Send deprecation notices to registered listeners. 79 | config.active_support.deprecation = :notify 80 | 81 | # Use default logging formatter so that PID and timestamp are not suppressed. 82 | config.log_formatter = ::Logger::Formatter.new 83 | 84 | # Use a different logger for distributed setups. 85 | # require 'syslog/logger' 86 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 87 | 88 | if ENV["RAILS_LOG_TO_STDOUT"].present? 89 | logger = ActiveSupport::Logger.new(STDOUT) 90 | logger.formatter = config.log_formatter 91 | config.logger = ActiveSupport::TaggedLogging.new(logger) 92 | end 93 | 94 | # Do not dump schema after migrations. 95 | config.active_record.dump_schema_after_migration = false 96 | end 97 | -------------------------------------------------------------------------------- /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 public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | 31 | # Store uploaded files on the local file system in a temporary directory 32 | config.active_storage.service = :test 33 | 34 | config.action_mailer.perform_caching = false 35 | 36 | # Tell Action Mailer not to deliver emails to the real world. 37 | # The :test delivery method accumulates sent emails in the 38 | # ActionMailer::Base.deliveries array. 39 | config.action_mailer.delivery_method = :test 40 | 41 | # Print deprecation notices to the stderr. 42 | config.active_support.deprecation = :stderr 43 | 44 | # Raises error for missing translations 45 | # config.action_view.raise_on_missing_translations = true 46 | end 47 | -------------------------------------------------------------------------------- /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/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 | # Add Yarn node_modules folder to the asset load path. 9 | Rails.application.config.assets.paths << Rails.root.join('node_modules') 10 | 11 | # Precompile additional assets. 12 | # application.js, application.css, and all non-JS/CSS in the app/assets 13 | # folder are already added. 14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/initializers/carrierwave.rb: -------------------------------------------------------------------------------- 1 | CarrierWave.configure do |config| 2 | if Rails.env.staging? || Rails.env.production? 3 | config.fog_credentials = { 4 | provider: 'AWS', 5 | aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'], 6 | aws_secret_access_key: ENV['AWS_ACCESS_KEY_ID'], 7 | region: ENV['AWS_REGION'] 8 | } 9 | config.fog_public = false 10 | config.fog_directory = ENV['AWS_STORE_BUCKET'] 11 | config.storage = :fog 12 | else 13 | config.storage = :file 14 | end 15 | 16 | config.enable_processing = false if Rails.env.test? 17 | end 18 | -------------------------------------------------------------------------------- /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 | # Report CSP violations to a specified URI 23 | # For further information see the following documentation: 24 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only 25 | # Rails.application.config.content_security_policy_report_only = true 26 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/initializers/devise.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Use this hook to configure devise mailer, warden hooks and so forth. 4 | # Many of these configuration options can be set straight in your model. 5 | Devise.setup do |config| 6 | # The secret key used by Devise. Devise uses this key to generate 7 | # random tokens. Changing this key will render invalid all existing 8 | # confirmation, reset password and unlock tokens in the database. 9 | # Devise will use the `secret_key_base` as its `secret_key` 10 | # by default. You can change it below and use your own secret key. 11 | # config.secret_key = '8786a30c3e56cbda61d96523a2b62e6e18efbfd71839cd66824780549c56537faafe4d251c0b757c8f69fca84b49395785c2bd312781fb9448f0ccdde27782e9' 12 | 13 | # ==> Controller configuration 14 | # Configure the parent class to the devise controllers. 15 | # config.parent_controller = 'DeviseController' 16 | 17 | # ==> Mailer Configuration 18 | # Configure the e-mail address which will be shown in Devise::Mailer, 19 | # note that it will be overwritten if you use your own mailer class 20 | # with default "from" parameter. 21 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' 22 | 23 | # Configure the class responsible to send e-mails. 24 | # config.mailer = 'Devise::Mailer' 25 | 26 | # Configure the parent class responsible to send e-mails. 27 | # config.parent_mailer = 'ActionMailer::Base' 28 | 29 | # ==> ORM configuration 30 | # Load and configure the ORM. Supports :active_record (default) and 31 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 32 | # available as additional gems. 33 | require 'devise/orm/active_record' 34 | 35 | # ==> Configuration for any authentication mechanism 36 | # Configure which keys are used when authenticating a user. The default is 37 | # just :email. You can configure it to use [:username, :subdomain], so for 38 | # authenticating a user, both parameters are required. Remember that those 39 | # parameters are used only when authenticating and not when retrieving from 40 | # session. If you need permissions, you should implement that in a before filter. 41 | # You can also supply a hash where the value is a boolean determining whether 42 | # or not authentication should be aborted when the value is not present. 43 | # config.authentication_keys = [:email] 44 | 45 | # Configure parameters from the request object used for authentication. Each entry 46 | # given should be a request method and it will automatically be passed to the 47 | # find_for_authentication method and considered in your model lookup. For instance, 48 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 49 | # The same considerations mentioned for authentication_keys also apply to request_keys. 50 | # config.request_keys = [] 51 | 52 | # Configure which authentication keys should be case-insensitive. 53 | # These keys will be downcased upon creating or modifying a user and when used 54 | # to authenticate or find a user. Default is :email. 55 | config.case_insensitive_keys = [:email] 56 | 57 | # Configure which authentication keys should have whitespace stripped. 58 | # These keys will have whitespace before and after removed upon creating or 59 | # modifying a user and when used to authenticate or find a user. Default is :email. 60 | config.strip_whitespace_keys = [:email] 61 | 62 | # Tell if authentication through request.params is enabled. True by default. 63 | # It can be set to an array that will enable params authentication only for the 64 | # given strategies, for example, `config.params_authenticatable = [:database]` will 65 | # enable it only for database (email + password) authentication. 66 | # config.params_authenticatable = true 67 | 68 | # Tell if authentication through HTTP Auth is enabled. False by default. 69 | # It can be set to an array that will enable http authentication only for the 70 | # given strategies, for example, `config.http_authenticatable = [:database]` will 71 | # enable it only for database authentication. The supported strategies are: 72 | # :database = Support basic authentication with authentication key + password 73 | # config.http_authenticatable = false 74 | 75 | # If 401 status code should be returned for AJAX requests. True by default. 76 | # config.http_authenticatable_on_xhr = true 77 | 78 | # The realm used in Http Basic Authentication. 'Application' by default. 79 | # config.http_authentication_realm = 'Application' 80 | 81 | # It will change confirmation, password recovery and other workflows 82 | # to behave the same regardless if the e-mail provided was right or wrong. 83 | # Does not affect registerable. 84 | # config.paranoid = true 85 | 86 | # By default Devise will store the user in session. You can skip storage for 87 | # particular strategies by setting this option. 88 | # Notice that if you are skipping storage for all authentication paths, you 89 | # may want to disable generating routes to Devise's sessions controller by 90 | # passing skip: :sessions to `devise_for` in your config/routes.rb 91 | config.skip_session_storage = [:http_auth] 92 | 93 | # By default, Devise cleans up the CSRF token on authentication to 94 | # avoid CSRF token fixation attacks. This means that, when using AJAX 95 | # requests for sign in and sign up, you need to get a new CSRF token 96 | # from the server. You can disable this option at your own risk. 97 | # config.clean_up_csrf_token_on_authentication = true 98 | 99 | # When false, Devise will not attempt to reload routes on eager load. 100 | # This can reduce the time taken to boot the app but if your application 101 | # requires the Devise mappings to be loaded during boot time the application 102 | # won't boot properly. 103 | # config.reload_routes = true 104 | 105 | # ==> Configuration for :database_authenticatable 106 | # For bcrypt, this is the cost for hashing the password and defaults to 11. If 107 | # using other algorithms, it sets how many times you want the password to be hashed. 108 | # 109 | # Limiting the stretches to just one in testing will increase the performance of 110 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 111 | # a value less than 10 in other environments. Note that, for bcrypt (the default 112 | # algorithm), the cost increases exponentially with the number of stretches (e.g. 113 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). 114 | config.stretches = Rails.env.test? ? 1 : 11 115 | 116 | # Set up a pepper to generate the hashed password. 117 | # config.pepper = 'e3766e4a8f6e961276c4ce5100dc1e98c248ff862e2c60783fa49f7e91049303fb89c5b5b224773a108f2365365a332e70a09fb2a8e5bec257e7b05339f007c8' 118 | 119 | # Send a notification to the original email when the user's email is changed. 120 | # config.send_email_changed_notification = false 121 | 122 | # Send a notification email when the user's password is changed. 123 | # config.send_password_change_notification = false 124 | 125 | # ==> Configuration for :confirmable 126 | # A period that the user is allowed to access the website even without 127 | # confirming their account. For instance, if set to 2.days, the user will be 128 | # able to access the website for two days without confirming their account, 129 | # access will be blocked just in the third day. 130 | # You can also set it to nil, which will allow the user to access the website 131 | # without confirming their account. 132 | # Default is 0.days, meaning the user cannot access the website without 133 | # confirming their account. 134 | # config.allow_unconfirmed_access_for = 2.days 135 | 136 | # A period that the user is allowed to confirm their account before their 137 | # token becomes invalid. For example, if set to 3.days, the user can confirm 138 | # their account within 3 days after the mail was sent, but on the fourth day 139 | # their account can't be confirmed with the token any more. 140 | # Default is nil, meaning there is no restriction on how long a user can take 141 | # before confirming their account. 142 | # config.confirm_within = 3.days 143 | 144 | # If true, requires any email changes to be confirmed (exactly the same way as 145 | # initial account confirmation) to be applied. Requires additional unconfirmed_email 146 | # db field (see migrations). Until confirmed, new email is stored in 147 | # unconfirmed_email column, and copied to email column on successful confirmation. 148 | config.reconfirmable = true 149 | 150 | # Defines which key will be used when confirming an account 151 | # config.confirmation_keys = [:email] 152 | 153 | # ==> Configuration for :rememberable 154 | # The time the user will be remembered without asking for credentials again. 155 | # config.remember_for = 2.weeks 156 | 157 | # Invalidates all the remember me tokens when the user signs out. 158 | config.expire_all_remember_me_on_sign_out = true 159 | 160 | # If true, extends the user's remember period when remembered via cookie. 161 | # config.extend_remember_period = false 162 | 163 | # Options to be passed to the created cookie. For instance, you can set 164 | # secure: true in order to force SSL only cookies. 165 | # config.rememberable_options = {} 166 | 167 | # ==> Configuration for :validatable 168 | # Range for password length. 169 | config.password_length = 6..128 170 | 171 | # Email regex used to validate email formats. It simply asserts that 172 | # one (and only one) @ exists in the given string. This is mainly 173 | # to give user feedback and not to assert the e-mail validity. 174 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ 175 | 176 | # ==> Configuration for :timeoutable 177 | # The time you want to timeout the user session without activity. After this 178 | # time the user will be asked for credentials again. Default is 30 minutes. 179 | # config.timeout_in = 30.minutes 180 | 181 | # ==> Configuration for :lockable 182 | # Defines which strategy will be used to lock an account. 183 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 184 | # :none = No lock strategy. You should handle locking by yourself. 185 | # config.lock_strategy = :failed_attempts 186 | 187 | # Defines which key will be used when locking and unlocking an account 188 | # config.unlock_keys = [:email] 189 | 190 | # Defines which strategy will be used to unlock an account. 191 | # :email = Sends an unlock link to the user email 192 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 193 | # :both = Enables both strategies 194 | # :none = No unlock strategy. You should handle unlocking by yourself. 195 | # config.unlock_strategy = :both 196 | 197 | # Number of authentication tries before locking an account if lock_strategy 198 | # is failed attempts. 199 | # config.maximum_attempts = 20 200 | 201 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 202 | # config.unlock_in = 1.hour 203 | 204 | # Warn on the last attempt before the account is locked. 205 | # config.last_attempt_warning = true 206 | 207 | # ==> Configuration for :recoverable 208 | # 209 | # Defines which key will be used when recovering the password for an account 210 | # config.reset_password_keys = [:email] 211 | 212 | # Time interval you can reset your password with a reset password key. 213 | # Don't put a too small interval or your users won't have the time to 214 | # change their passwords. 215 | config.reset_password_within = 6.hours 216 | 217 | # When set to false, does not sign a user in automatically after their password is 218 | # reset. Defaults to true, so a user is signed in automatically after a reset. 219 | # config.sign_in_after_reset_password = true 220 | 221 | # ==> Configuration for :encryptable 222 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default). 223 | # You can use :sha1, :sha512 or algorithms from others authentication tools as 224 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 225 | # for default behavior) and :restful_authentication_sha1 (then you should set 226 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). 227 | # 228 | # Require the `devise-encryptable` gem when using anything other than bcrypt 229 | # config.encryptor = :sha512 230 | 231 | # ==> Scopes configuration 232 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 233 | # "users/sessions/new". It's turned off by default because it's slower if you 234 | # are using only default views. 235 | # config.scoped_views = false 236 | 237 | # Configure the default scope given to Warden. By default it's the first 238 | # devise role declared in your routes (usually :user). 239 | # config.default_scope = :user 240 | 241 | # Set this configuration to false if you want /users/sign_out to sign out 242 | # only the current scope. By default, Devise signs out all scopes. 243 | # config.sign_out_all_scopes = true 244 | 245 | # ==> Navigation configuration 246 | # Lists the formats that should be treated as navigational. Formats like 247 | # :html, should redirect to the sign in page when the user does not have 248 | # access, but formats like :xml or :json, should return 401. 249 | # 250 | # If you have any extra navigational formats, like :iphone or :mobile, you 251 | # should add them to the navigational formats lists. 252 | # 253 | # The "*/*" below is required to match Internet Explorer requests. 254 | # config.navigational_formats = ['*/*', :html] 255 | 256 | # The default HTTP method used to sign out a resource. Default is :delete. 257 | config.sign_out_via = :delete 258 | 259 | # ==> OmniAuth 260 | # Add a new OmniAuth provider. Check the wiki for more information on setting 261 | # up on your models and hooks. 262 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' 263 | 264 | # ==> Warden configuration 265 | # If you want to use other strategies, that are not supported by Devise, or 266 | # change the failure app, you can configure them inside the config.warden block. 267 | # 268 | # config.warden do |manager| 269 | # manager.intercept_401 = false 270 | # manager.default_strategies(scope: :user).unshift :some_external_strategy 271 | # end 272 | 273 | # ==> Mountable engine configurations 274 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine 275 | # is mountable, there are some extra configurations to be taken into account. 276 | # The following options are available, assuming the engine is mounted as: 277 | # 278 | # mount MyEngine, at: '/my_engine' 279 | # 280 | # The router that invoked `devise_for`, in the example above, would be: 281 | # config.router_name = :my_engine 282 | # 283 | # When using OmniAuth, Devise cannot automatically set OmniAuth path, 284 | # so you need to do it manually. For the users scope, it would be: 285 | # config.omniauth_path_prefix = '/my_engine/users/auth' 286 | 287 | # ==> Turbolinks configuration 288 | # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly: 289 | # 290 | # ActiveSupport.on_load(:devise_failure_app) do 291 | # include Turbolinks::Controller 292 | # end 293 | 294 | # ==> Configuration for :registerable 295 | 296 | # When set to false, does not sign a user in automatically after their password is 297 | # changed. Defaults to true, so a user is signed in automatically after changing a password. 298 | # config.sign_in_after_change_password = true 299 | end 300 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/initializers/kaminari_config.rb: -------------------------------------------------------------------------------- 1 | Kaminari.configure do |config| 2 | # config.default_per_page = 25 3 | # config.max_per_page = nil 4 | # config.window = 4 5 | # config.outer_window = 0 6 | # config.left = 0 7 | # config.right = 0 8 | # config.page_method_name = :page 9 | # config.param_name = :page 10 | # config.params_on_first_page = false 11 | end 12 | -------------------------------------------------------------------------------- /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 | 6 | # Add new mime types for use in wicked_pdf: 7 | Mime::Type.register 'application/pdf', :pdf 8 | -------------------------------------------------------------------------------- /config/initializers/rack_mini_profiler.rb: -------------------------------------------------------------------------------- 1 | require 'rack-mini-profiler' 2 | 3 | Rack::MiniProfilerRails.initialize!(Rails.application) if Rails.env.development? 4 | -------------------------------------------------------------------------------- /config/initializers/sentry.rb: -------------------------------------------------------------------------------- 1 | Raven.configure do |config| 2 | config.environments = %w[ staging production ] 3 | config.dsn = ENV['SENTRY_DSN'] 4 | end 5 | -------------------------------------------------------------------------------- /config/initializers/sidekiq.rb: -------------------------------------------------------------------------------- 1 | Sidekiq.configure_server do |config| 2 | config.redis = { url: ENV['REDIS_URL'] } 3 | end 4 | 5 | Sidekiq.configure_client do |config| 6 | config.redis = { url: ENV['REDIS_URL'] } 7 | end 8 | -------------------------------------------------------------------------------- /config/initializers/simple_form.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # 3 | # Uncomment this and change the path if necessary to include your own 4 | # components. 5 | # See https://github.com/plataformatec/simple_form#custom-components to know 6 | # more about custom components. 7 | # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f } 8 | # 9 | # Use this setup block to configure all options available in SimpleForm. 10 | SimpleForm.setup do |config| 11 | # Wrappers are used by the form builder to generate a 12 | # complete input. You can remove any component from the 13 | # wrapper, change the order or even add your own to the 14 | # stack. The options given below are used to wrap the 15 | # whole input. 16 | config.wrappers :default, class: :input, 17 | hint_class: :field_with_hint, error_class: :field_with_errors, valid_class: :field_without_errors do |b| 18 | ## Extensions enabled by default 19 | # Any of these extensions can be disabled for a 20 | # given input by passing: `f.input EXTENSION_NAME => false`. 21 | # You can make any of these extensions optional by 22 | # renaming `b.use` to `b.optional`. 23 | 24 | # Determines whether to use HTML5 (:email, :url, ...) 25 | # and required attributes 26 | b.use :html5 27 | 28 | # Calculates placeholders automatically from I18n 29 | # You can also pass a string as f.input placeholder: "Placeholder" 30 | b.use :placeholder 31 | 32 | ## Optional extensions 33 | # They are disabled unless you pass `f.input EXTENSION_NAME => true` 34 | # to the input. If so, they will retrieve the values from the model 35 | # if any exists. If you want to enable any of those 36 | # extensions by default, you can change `b.optional` to `b.use`. 37 | 38 | # Calculates maxlength from length validations for string inputs 39 | # and/or database column lengths 40 | b.optional :maxlength 41 | 42 | # Calculate minlength from length validations for string inputs 43 | b.optional :minlength 44 | 45 | # Calculates pattern from format validations for string inputs 46 | b.optional :pattern 47 | 48 | # Calculates min and max from length validations for numeric inputs 49 | b.optional :min_max 50 | 51 | # Calculates readonly automatically from readonly attributes 52 | b.optional :readonly 53 | 54 | ## Inputs 55 | # b.use :input, class: 'input', error_class: 'is-invalid', valid_class: 'is-valid' 56 | b.use :label_input 57 | b.use :hint, wrap_with: { tag: :span, class: :hint } 58 | b.use :error, wrap_with: { tag: :span, class: :error } 59 | 60 | ## full_messages_for 61 | # If you want to display the full error message for the attribute, you can 62 | # use the component :full_error, like: 63 | # 64 | # b.use :full_error, wrap_with: { tag: :span, class: :error } 65 | end 66 | 67 | # The default wrapper to be used by the FormBuilder. 68 | config.default_wrapper = :default 69 | 70 | # Define the way to render check boxes / radio buttons with labels. 71 | # Defaults to :nested for bootstrap config. 72 | # inline: input + label 73 | # nested: label > input 74 | config.boolean_style = :nested 75 | 76 | # Default class for buttons 77 | config.button_class = 'btn' 78 | 79 | # Method used to tidy up errors. Specify any Rails Array method. 80 | # :first lists the first message for each field. 81 | # Use :to_sentence to list all errors for each field. 82 | # config.error_method = :first 83 | 84 | # Default tag used for error notification helper. 85 | config.error_notification_tag = :div 86 | 87 | # CSS class to add for error notification helper. 88 | config.error_notification_class = 'error_notification' 89 | 90 | # Series of attempts to detect a default label method for collection. 91 | # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] 92 | 93 | # Series of attempts to detect a default value method for collection. 94 | # config.collection_value_methods = [ :id, :to_s ] 95 | 96 | # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. 97 | # config.collection_wrapper_tag = nil 98 | 99 | # You can define the class to use on all collection wrappers. Defaulting to none. 100 | # config.collection_wrapper_class = nil 101 | 102 | # You can wrap each item in a collection of radio/check boxes with a tag, 103 | # defaulting to :span. 104 | # config.item_wrapper_tag = :span 105 | 106 | # You can define a class to use in all item wrappers. Defaulting to none. 107 | # config.item_wrapper_class = nil 108 | 109 | # How the label text should be generated altogether with the required text. 110 | config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } 111 | 112 | # You can define the class to use on all labels. Default is nil. 113 | # config.label_class = nil 114 | 115 | # You can define the default class to be used on forms. Can be overriden 116 | # with `html: { :class }`. Defaulting to none. 117 | # config.default_form_class = nil 118 | 119 | # You can define which elements should obtain additional classes 120 | # config.generate_additional_classes_for = [:wrapper, :label, :input] 121 | 122 | # Whether attributes are required by default (or not). Default is true. 123 | # config.required_by_default = true 124 | 125 | # Tell browsers whether to use the native HTML5 validations (novalidate form option). 126 | # These validations are enabled in SimpleForm's internal config but disabled by default 127 | # in this configuration, which is recommended due to some quirks from different browsers. 128 | # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, 129 | # change this configuration to true. 130 | config.browser_validations = false 131 | 132 | # Collection of methods to detect if a file type was given. 133 | # config.file_methods = [ :mounted_as, :file?, :public_filename, :attached? ] 134 | 135 | # Custom mappings for input types. This should be a hash containing a regexp 136 | # to match as key, and the input type that will be used when the field name 137 | # matches the regexp as value. 138 | # config.input_mappings = { /count/ => :integer } 139 | 140 | # Custom wrappers for input types. This should be a hash containing an input 141 | # type as key and the wrapper that will be used for all inputs with specified type. 142 | # config.wrapper_mappings = { string: :prepend } 143 | 144 | # Namespaces where SimpleForm should look for custom input classes that 145 | # override default inputs. 146 | # config.custom_inputs_namespaces << "CustomInputs" 147 | 148 | # Default priority for time_zone inputs. 149 | # config.time_zone_priority = nil 150 | 151 | # Default priority for country inputs. 152 | # config.country_priority = nil 153 | 154 | # When false, do not use translations for labels. 155 | # config.translate_labels = true 156 | 157 | # Automatically discover new inputs in Rails' autoload path. 158 | # config.inputs_discovery = true 159 | 160 | # Cache SimpleForm inputs discovery 161 | # config.cache_discovery = !Rails.env.development? 162 | 163 | # Default class for inputs 164 | # config.input_class = nil 165 | 166 | # Define the default class of the input wrapper of the boolean input. 167 | config.boolean_label_class = 'checkbox' 168 | 169 | # Defines if the default input wrapper class should be included in radio 170 | # collection wrappers. 171 | # config.include_default_input_wrapper_class = true 172 | 173 | # Defines which i18n scope will be used in Simple Form. 174 | # config.i18n_scope = 'simple_form' 175 | 176 | # Defines validation classes to the input_field. By default it's nil. 177 | # config.input_field_valid_class = 'is-valid' 178 | # config.input_field_error_class = 'is-invalid' 179 | end 180 | -------------------------------------------------------------------------------- /config/initializers/wicked_pdf.rb: -------------------------------------------------------------------------------- 1 | # WickedPDF Global Configuration 2 | # 3 | # Use this to set up shared configuration options for your entire application. 4 | # Any of the configuration options shown here can also be applied to single 5 | # models by passing arguments to the `render :pdf` call. 6 | # 7 | # To learn more, check out the README: 8 | # 9 | # https://github.com/mileszs/wicked_pdf/blob/master/README.md 10 | 11 | WickedPdf.config = { 12 | # Path to the wkhtmltopdf executable: This usually isn't needed if using 13 | # one of the wkhtmltopdf-binary family of gems. 14 | # exe_path: '/usr/local/bin/wkhtmltopdf', 15 | # or 16 | # exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf') 17 | 18 | # Layout file to be used for all PDFs 19 | # (but can be overridden in `render :pdf` calls) 20 | # layout: 'pdf.html', 21 | } 22 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/locales/devise.en.yml: -------------------------------------------------------------------------------- 1 | # Additional translations at https://github.com/plataformatec/devise/wiki/I18n 2 | 3 | en: 4 | devise: 5 | confirmations: 6 | confirmed: "Your email address has been successfully confirmed." 7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." 8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." 9 | failure: 10 | already_authenticated: "You are already signed in." 11 | inactive: "Your account is not activated yet." 12 | invalid: "Invalid %{authentication_keys} or password." 13 | locked: "Your account is locked." 14 | last_attempt: "You have one more attempt before your account is locked." 15 | not_found_in_database: "Invalid %{authentication_keys} or password." 16 | timeout: "Your session expired. Please sign in again to continue." 17 | unauthenticated: "You need to sign in or sign up before continuing." 18 | unconfirmed: "You have to confirm your email address before continuing." 19 | mailer: 20 | confirmation_instructions: 21 | subject: "Confirmation instructions" 22 | reset_password_instructions: 23 | subject: "Reset password instructions" 24 | unlock_instructions: 25 | subject: "Unlock instructions" 26 | email_changed: 27 | subject: "Email Changed" 28 | password_change: 29 | subject: "Password Changed" 30 | omniauth_callbacks: 31 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"." 32 | success: "Successfully authenticated from %{kind} account." 33 | passwords: 34 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." 35 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." 36 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." 37 | updated: "Your password has been changed successfully. You are now signed in." 38 | updated_not_active: "Your password has been changed successfully." 39 | registrations: 40 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." 41 | signed_up: "Welcome! You have signed up successfully." 42 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." 43 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." 44 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." 45 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address." 46 | updated: "Your account has been updated successfully." 47 | updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again" 48 | sessions: 49 | signed_in: "Signed in successfully." 50 | signed_out: "Signed out successfully." 51 | already_signed_out: "Signed out successfully." 52 | unlocks: 53 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." 54 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." 55 | unlocked: "Your account has been unlocked successfully. Please sign in to continue." 56 | errors: 57 | messages: 58 | already_confirmed: "was already confirmed, please try signing in" 59 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" 60 | expired: "has expired, please request a new one" 61 | not_found: "not found" 62 | not_locked: "was not locked" 63 | not_saved: 64 | one: "1 error prohibited this %{resource} from being saved:" 65 | other: "%{count} errors prohibited this %{resource} from being saved:" 66 | -------------------------------------------------------------------------------- /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 http://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /config/locales/pundit.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | pundit: 3 | default: 'Access Denied' 4 | -------------------------------------------------------------------------------- /config/locales/simple_form.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | simple_form: 3 | "yes": 'Yes' 4 | "no": 'No' 5 | required: 6 | text: 'required' 7 | mark: '*' 8 | # You can uncomment the line below if you need to overwrite the whole required html. 9 | # When using html, text and mark won't be used. 10 | # html: '*' 11 | error_notification: 12 | default_message: "Please review the problems below:" 13 | # Examples 14 | # labels: 15 | # defaults: 16 | # password: 'Password' 17 | # user: 18 | # new: 19 | # email: 'E-mail to sign in.' 20 | # edit: 21 | # email: 'E-mail.' 22 | # hints: 23 | # defaults: 24 | # username: 'User name to sign in.' 25 | # password: 'No special characters, please.' 26 | # include_blanks: 27 | # defaults: 28 | # age: 'Rather not say' 29 | # prompts: 30 | # defaults: 31 | # age: 'Select your age' 32 | -------------------------------------------------------------------------------- /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 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 11 | # 12 | port ENV.fetch("PORT") { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch("RAILS_ENV") { "development" } 17 | 18 | # Specifies the number of `workers` to boot in clustered mode. 19 | # Workers are forked webserver processes. If using threads and workers together 20 | # the concurrency of the application would be max `threads` * `workers`. 21 | # Workers do not work on JRuby or Windows (both of which do not support 22 | # processes). 23 | # 24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 25 | 26 | # Use the `preload_app!` method when specifying a `workers` number. 27 | # This directive tells Puma to first boot the application and load code 28 | # before forking the application. This takes advantage of Copy On Write 29 | # process behavior so workers use less memory. 30 | # 31 | # preload_app! 32 | 33 | # Allow puma to be restarted by `rails restart` command. 34 | plugin :tmp_restart 35 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | require 'sidekiq/web' 2 | 3 | Rails.application.routes.draw do 4 | devise_for :users 5 | mount Sidekiq::Web => '/sidekiq' 6 | 7 | root to: 'home#index' 8 | end 9 | -------------------------------------------------------------------------------- /config/sidekiq.yml: -------------------------------------------------------------------------------- 1 | :concurrency: 5 2 | :queues: 3 | - default 4 | - mailers 5 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w[ 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ].each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /db/migrate/20190601095148_devise_create_users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class DeviseCreateUsers < ActiveRecord::Migration[5.2] 4 | def change 5 | create_table :users do |t| 6 | ## Database authenticatable 7 | t.string :email, null: false, default: "" 8 | t.string :encrypted_password, null: false, default: "" 9 | 10 | ## Recoverable 11 | t.string :reset_password_token 12 | t.datetime :reset_password_sent_at 13 | 14 | ## Rememberable 15 | t.datetime :remember_created_at 16 | 17 | ## Trackable 18 | # t.integer :sign_in_count, default: 0, null: false 19 | # t.datetime :current_sign_in_at 20 | # t.datetime :last_sign_in_at 21 | # t.inet :current_sign_in_ip 22 | # t.inet :last_sign_in_ip 23 | 24 | ## Confirmable 25 | # t.string :confirmation_token 26 | # t.datetime :confirmed_at 27 | # t.datetime :confirmation_sent_at 28 | # t.string :unconfirmed_email # Only if using reconfirmable 29 | 30 | ## Lockable 31 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts 32 | # t.string :unlock_token # Only if unlock strategy is :email or :both 33 | # t.datetime :locked_at 34 | 35 | 36 | t.timestamps null: false 37 | end 38 | 39 | add_index :users, :email, unique: true 40 | add_index :users, :reset_password_token, unique: true 41 | # add_index :users, :confirmation_token, unique: true 42 | # add_index :users, :unlock_token, unique: true 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /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 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 2019_06_01_095148) do 14 | 15 | # These are extensions that must be enabled in order to support this database 16 | enable_extension "plpgsql" 17 | 18 | create_table "users", force: :cascade do |t| 19 | t.string "email", default: "", null: false 20 | t.string "encrypted_password", default: "", null: false 21 | t.string "reset_password_token" 22 | t.datetime "reset_password_sent_at" 23 | t.datetime "remember_created_at" 24 | t.datetime "created_at", null: false 25 | t.datetime "updated_at", null: false 26 | t.index ["email"], name: "index_users_on_email", unique: true 27 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 28 | end 29 | 30 | end 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docs/pull_request_template.md: -------------------------------------------------------------------------------- 1 | **Issue** 2 | # Issue number 3 | 4 | **Describe** 5 | # detail description 6 | 7 | **Screenshots** 8 | # Attachment if any change on layout 9 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/lib/tasks/.keep -------------------------------------------------------------------------------- /lib/tasks/auto_annotate_models.rake: -------------------------------------------------------------------------------- 1 | # NOTE: only doing this in development as some production environments (Heroku) 2 | # NOTE: are sensitive to local FS writes, and besides -- it's just not proper 3 | # NOTE: to have a dev-mode tool do its thing in production. 4 | if Rails.env.development? 5 | require 'annotate' 6 | task :set_annotation_options do 7 | # You can override any of these by setting an environment variable of the 8 | # same name. 9 | Annotate.set_defaults( 10 | 'routes' => 'false', 11 | 'position_in_routes' => 'before', 12 | 'position_in_class' => 'before', 13 | 'position_in_test' => 'before', 14 | 'position_in_fixture' => 'before', 15 | 'position_in_factory' => 'before', 16 | 'position_in_serializer' => 'before', 17 | 'show_foreign_keys' => 'true', 18 | 'show_complete_foreign_keys' => 'false', 19 | 'show_indexes' => 'true', 20 | 'simple_indexes' => 'false', 21 | 'model_dir' => 'app/models', 22 | 'root_dir' => '', 23 | 'include_version' => 'false', 24 | 'require' => '', 25 | 'exclude_tests' => 'false', 26 | 'exclude_fixtures' => 'false', 27 | 'exclude_factories' => 'false', 28 | 'exclude_serializers' => 'false', 29 | 'exclude_scaffolds' => 'true', 30 | 'exclude_controllers' => 'true', 31 | 'exclude_helpers' => 'true', 32 | 'exclude_sti_subclasses' => 'false', 33 | 'ignore_model_sub_dir' => 'false', 34 | 'ignore_columns' => nil, 35 | 'ignore_routes' => nil, 36 | 'ignore_unknown_models' => 'false', 37 | 'hide_limit_column_types' => 'integer,bigint,boolean', 38 | 'hide_default_column_types' => 'json,jsonb,hstore', 39 | 'skip_on_db_migrate' => 'false', 40 | 'format_bare' => 'true', 41 | 'format_rdoc' => 'false', 42 | 'format_markdown' => 'false', 43 | 'sort' => 'false', 44 | 'force' => 'false', 45 | 'frozen' => 'false', 46 | 'classified_sort' => 'true', 47 | 'trace' => 'false', 48 | 'wrapper_open' => nil, 49 | 'wrapper_close' => nil, 50 | 'with_comment' => 'true' 51 | ) 52 | end 53 | 54 | Annotate.load_tasks 55 | end 56 | -------------------------------------------------------------------------------- /lib/templates/erb/scaffold/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%# frozen_string_literal: true %> 2 | <%%= simple_form_for(@<%= singular_table_name %>) do |f| %> 3 | <%%= f.error_notification %> 4 | <%%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> 5 | 6 |
7 | <%- attributes.each do |attribute| -%> 8 | <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %> 9 | <%- end -%> 10 |
11 | 12 |
13 | <%%= f.button :submit %> 14 |
15 | <%% end %> 16 | -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/log/.keep -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "go_rails_template", 3 | "private": true, 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/public/apple-touch-icon.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/public/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /spec/controllers/home_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe HomeController, type: :controller do 4 | describe 'GET #index' do 5 | it 'returns http success' do 6 | get :index 7 | expect(response).to have_http_status(:success) 8 | expect(response).to render_template(:index) 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/factories/users.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: users 4 | # 5 | # id :bigint not null, primary key 6 | # email :string default(""), not null 7 | # encrypted_password :string default(""), not null 8 | # remember_created_at :datetime 9 | # reset_password_sent_at :datetime 10 | # reset_password_token :string 11 | # created_at :datetime not null 12 | # updated_at :datetime not null 13 | # 14 | # Indexes 15 | # 16 | # index_users_on_email (email) UNIQUE 17 | # index_users_on_reset_password_token (reset_password_token) UNIQUE 18 | # 19 | 20 | FactoryBot.define do 21 | factory :user do 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: users 4 | # 5 | # id :bigint not null, primary key 6 | # email :string default(""), not null 7 | # encrypted_password :string default(""), not null 8 | # remember_created_at :datetime 9 | # reset_password_sent_at :datetime 10 | # reset_password_token :string 11 | # created_at :datetime not null 12 | # updated_at :datetime not null 13 | # 14 | # Indexes 15 | # 16 | # index_users_on_email (email) UNIQUE 17 | # index_users_on_reset_password_token (reset_password_token) UNIQUE 18 | # 19 | 20 | require 'rails_helper' 21 | 22 | RSpec.describe User, type: :model do 23 | end 24 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | require 'simplecov' 2 | SimpleCov.start do 3 | add_filter 'app/models/application_record.rb' 4 | add_filter 'app/controllers/application_controller.rb' 5 | add_filter 'app/jobs/application_job.rb' 6 | add_filter 'app/mailers/application_mailer.rb' 7 | add_filter 'app/services/application_service.rb' 8 | add_filter 'app/forms/application_form.rb' 9 | add_filter 'app/queries/application_query.rb' 10 | add_filter 'app/calculations/application_calculation.rb' 11 | add_filter 'app/policies/application_policy.rb' 12 | add_filter 'app/decorators/application_decorator.rb' 13 | add_filter 'app/decorators/paginating_decorator.rb' 14 | add_filter 'config/' 15 | add_filter 'spec/' 16 | 17 | add_group 'Models', 'app/models' 18 | add_group 'Controllers', 'app/controllers' 19 | add_group 'Helpers', 'app/helpers' 20 | add_group 'Jobs', 'app/jobs' 21 | add_group 'Mailers', 'app/mailers' 22 | add_group 'Services', 'app/services' 23 | add_group 'Forms', 'app/forms' 24 | add_group 'Queries', 'app/queries' 25 | add_group 'Calculations', 'app/calculations' 26 | add_group 'Policies', 'app/policies' 27 | add_group 'Decorators', 'app/decorators' 28 | end 29 | 30 | require 'spec_helper' 31 | ENV['RAILS_ENV'] ||= 'test' 32 | 33 | require File.expand_path('../../config/environment', __FILE__) 34 | abort('The Rails environment is running in production mode!') if Rails.env.production? 35 | 36 | require 'rspec/rails' 37 | require 'faker' 38 | require 'vcr' 39 | 40 | Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } 41 | 42 | begin 43 | ActiveRecord::Migration.maintain_test_schema! 44 | rescue ActiveRecord::PendingMigrationError => e 45 | puts e.to_s.strip 46 | exit 1 47 | end 48 | 49 | VCR.configure do |c| 50 | c.cassette_library_dir = 'spec/vcr' 51 | c.hook_into :webmock 52 | c.configure_rspec_metadata! 53 | c.allow_http_connections_when_no_cassette = true 54 | end 55 | 56 | RSpec.configure do |config| 57 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 58 | config.use_transactional_fixtures = true 59 | config.infer_spec_type_from_file_location! 60 | config.filter_rails_from_backtrace! 61 | end 62 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | RSpec.configure do |config| 2 | config.expect_with :rspec do |expectations| 3 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 4 | end 5 | 6 | config.mock_with :rspec do |mocks| 7 | mocks.verify_partial_doubles = true 8 | end 9 | 10 | config.shared_context_metadata_behavior = :apply_to_host_groups 11 | end 12 | -------------------------------------------------------------------------------- /spec/support/devise.rb: -------------------------------------------------------------------------------- 1 | RSpec.configure do |config| 2 | config.include Devise::Test::ControllerHelpers, type: :controller 3 | end 4 | -------------------------------------------------------------------------------- /spec/support/factory_bot_rails.rb: -------------------------------------------------------------------------------- 1 | RSpec.configure do |config| 2 | config.include FactoryBot::Syntax::Methods 3 | end 4 | -------------------------------------------------------------------------------- /spec/support/json_parser.rb: -------------------------------------------------------------------------------- 1 | module JsonParser 2 | def json_response 3 | JSON.parse(response.body).with_indifferent_access 4 | end 5 | end 6 | 7 | RSpec.configure do |config| 8 | config.include JsonParser, type: :controller 9 | end 10 | -------------------------------------------------------------------------------- /spec/support/matchers/axlsx_matcher.rb: -------------------------------------------------------------------------------- 1 | RSpec::Matchers.define :have_header_cells do |cell_values| 2 | match do |worksheet| 3 | worksheet.rows[0].cells.map(&:value) == cell_values 4 | end 5 | 6 | failure_message do |actual| 7 | "Expected #{actual.rows[0].cells.map(&:value)} to be #{expected}" 8 | end 9 | end 10 | 11 | RSpec::Matchers.define :have_cells do |expected| 12 | match do |worksheet| 13 | worksheet.rows[@index].cells.map(&:value) == expected 14 | end 15 | 16 | chain :in_row do |index| 17 | @index = index 18 | end 19 | 20 | failure_message do |actual| 21 | "Expected #{actual.rows[@index].cells.map(&:value)} to include #{expected} at row #{@index}." 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/support/matchers/be_url_matcher.rb: -------------------------------------------------------------------------------- 1 | RSpec::Matchers.define :be_url do |_expected| 2 | match do |actual| 3 | begin 4 | URI.parse(actual) 5 | rescue 6 | false 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/support/matchers/have_attrs_matcher.rb: -------------------------------------------------------------------------------- 1 | RSpec::Matchers.define :have_attrs do |attrs| 2 | match do |actual| 3 | @matcher = have_attributes(attrs) 4 | @matcher.matches?(actual) 5 | end 6 | 7 | chain :with_nested do |*keys| 8 | new_attrs = attrs.except(*(keys.map { |key| :"#{key}_attributes" })) 9 | keys.each do |key| 10 | new_attrs[key] = have_attributes(attrs[:"#{key}_attributes"]) 11 | end 12 | attrs = new_attrs 13 | end 14 | 15 | failure_message do |_actual| 16 | @matcher.failure_message 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/support/matchers/not_change_matcher.rb: -------------------------------------------------------------------------------- 1 | RSpec::Matchers.define_negated_matcher :not_change, :change 2 | -------------------------------------------------------------------------------- /spec/support/matchers/redirect_via_turbolinks_to_matcher.rb: -------------------------------------------------------------------------------- 1 | RSpec::Matchers.define :redirect_via_turbolinks_to do |expected| 2 | match do |_actual| 3 | begin 4 | assert_response(:success) 5 | original_status = response.status 6 | response.status = 302 7 | assert_redirected_to(expected) 8 | response.status = original_status 9 | assert(response.body.starts_with?('Turbolinks.visit'), 'Expected response body to start with "Turbolinks.visit"') 10 | rescue ActiveSupport::TestCase::Assertion => e 11 | @failure_message = e.message 12 | false 13 | end 14 | end 15 | 16 | failure_message do |_actual| 17 | @failure_message 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /spec/support/shared_contexts/axlsx.rb: -------------------------------------------------------------------------------- 1 | RSpec.shared_context 'axlsx' do 2 | # all xlsx specs describe must be normalized 3 | # "folder/view_name.xlsx.axlsx" 4 | # allow to infer the template path 5 | template_name = description 6 | 7 | let(:template_path) do 8 | ['app', 'views', template_name] 9 | end 10 | 11 | # This helper will be used in tests 12 | def render_template(locals = {}) 13 | axlsx_binding = Kernel.binding 14 | locals.each do |key, value| 15 | axlsx_binding.local_variable_set key, value 16 | end 17 | # define a default workbook and a default sheet useful when testing partial in isolation 18 | wb = Axlsx::Package.new.workbook 19 | axlsx_binding.local_variable_set(:wb, wb) 20 | axlsx_binding.local_variable_set(:sheet, wb.add_worksheet) 21 | 22 | # mimics an ActionView::Template class, presenting a 'source' method 23 | # to retrieve the content of the template 24 | axlsx_binding.eval(ActionView::Template::Handlers::AxlsxBuilder.new.call(Struct.new(:source).new(File.read(Rails.root.join(*template_path))))) 25 | axlsx_binding.local_variable_get(:wb) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /spec/support/shoulda_matchers.rb: -------------------------------------------------------------------------------- 1 | Shoulda::Matchers.configure do |config| 2 | config.integrate do |with| 3 | with.test_framework :rspec 4 | with.library :rails 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/storage/.keep -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/tmp/.keep -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tranquangvu/go-rails-template/bcc6b93fbc51557f5300c21a4ad1b1f80fefe8ff/vendor/.keep --------------------------------------------------------------------------------