14 | <% end %>
15 |
16 | <%= render 'devise/shared/links' %>
17 |
--------------------------------------------------------------------------------
/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/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | ActiveAdmin.routes(self)
3 | get 'home/index'
4 | devise_for :users
5 | # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
6 |
7 | root to: 'home#index'
8 |
9 | # Feature switching with basic auth
10 | # https://github.com/jnunemaker/flipper/blob/master/docs/ui/README.md#basic-authentication-via-rack
11 | flipper_app = Flipper::UI.app(Flipper.instance) do |builder|
12 | builder.use Rack::Auth::Basic do |username, password|
13 | username == Rails.application.credentials.flipper[:user_name] &&
14 | password == Rails.application.credentials.flipper[:password]
15 | end
16 | end
17 | mount flipper_app, at: '/flipper'
18 | end
19 |
--------------------------------------------------------------------------------
/app/javascript/packs/application.js:
--------------------------------------------------------------------------------
1 | // This file is automatically compiled by Webpack, along with any other files
2 | // present in this directory. You're encouraged to place your actual application logic in
3 | // a relevant structure within app/javascript and only use these pack files to reference
4 | // that code so it'll be compiled.
5 |
6 | require("@rails/ujs").start()
7 | require("turbolinks").start()
8 | require("@rails/activestorage").start()
9 | require("channels")
10 |
11 |
12 | // Uncomment to copy all static images under ../images to the output folder and reference
13 | // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
14 | // or the `imagePath` JavaScript helper below.
15 | //
16 | // const images = require.context('../images', true)
17 | // const imagePath = (name) => images(name, true)
18 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6 | * vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_self
14 | */
15 |
16 | // Custom bootstrap variables must be set or imported *before* bootstrap.
17 | @import "bootstrap";
18 |
19 | // Our App Styles
20 | @import "home";
21 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative 'boot'
2 |
3 | require 'rails/all'
4 | require 'flipper/middleware/memoizer'
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 RailsTemplate
11 | class Application < Rails::Application
12 | # Initialize configuration defaults for originally generated Rails version.
13 | config.load_defaults 6.0
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 | if Rails.env == 'production'
21 | config.middleware.use Flipper::Middleware::Memoizer, preload_all: true
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # 'true': 'foo'
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at https://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/app/views/devise/sessions/new.html.erb:
--------------------------------------------------------------------------------
1 |
26 | <% end %>
27 |
28 | <%= render 'devise/shared/links' %>
29 |
--------------------------------------------------------------------------------
/app/admin/dashboard.rb:
--------------------------------------------------------------------------------
1 | ActiveAdmin.register_page 'Dashboard' do
2 | menu priority: 1, label: proc { I18n.t('active_admin.dashboard') }
3 |
4 | content title: proc { I18n.t('active_admin.dashboard') } do
5 | div class: 'blank_slate_container', id: 'dashboard_default_message' do
6 | span class: 'blank_slate' do
7 | span I18n.t('active_admin.dashboard_welcome.welcome')
8 | small I18n.t('active_admin.dashboard_welcome.call_to_action')
9 | end
10 | end
11 |
12 | # Here is an example of a simple dashboard with columns and panels.
13 | #
14 | # columns do
15 | # column do
16 | # panel 'Recent Posts' do
17 | # ul do
18 | # Post.recent(5).map do |post|
19 | # li link_to(post.title, admin_post_path(post))
20 | # end
21 | # end
22 | # end
23 | # end
24 |
25 | # column do
26 | # panel 'Info' do
27 | # para 'Welcome to ActiveAdmin.'
28 | # end
29 | # end
30 | # end
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/app/views/devise/passwords/edit.html.erb:
--------------------------------------------------------------------------------
1 |
24 | <% end %>
25 |
26 | <%= render 'devise/shared/links' %>
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Tristan Toye
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 |
--------------------------------------------------------------------------------
/app/views/devise/registrations/new.html.erb:
--------------------------------------------------------------------------------
1 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = function(api) {
2 | var validEnv = ['development', 'test', 'production']
3 | var currentEnv = api.env()
4 | var isDevelopmentEnv = api.env('development')
5 | var isProductionEnv = api.env('production')
6 | var isTestEnv = api.env('test')
7 |
8 | if (!validEnv.includes(currentEnv)) {
9 | throw new Error(
10 | 'Please specify a valid `NODE_ENV` or ' +
11 | '`BABEL_ENV` environment variables. Valid values are "development", ' +
12 | '"test", and "production". Instead, received: ' +
13 | JSON.stringify(currentEnv) +
14 | '.'
15 | )
16 | }
17 |
18 | return {
19 | presets: [
20 | isTestEnv && [
21 | '@babel/preset-env',
22 | {
23 | targets: {
24 | node: 'current'
25 | }
26 | }
27 | ],
28 | (isProductionEnv || isDevelopmentEnv) && [
29 | '@babel/preset-env',
30 | {
31 | forceAllTransforms: true,
32 | useBuiltIns: 'entry',
33 | corejs: 3,
34 | modules: false,
35 | exclude: ['transform-typeof-symbol']
36 | }
37 | ]
38 | ].filter(Boolean),
39 | plugins: [
40 | 'babel-plugin-macros',
41 | '@babel/plugin-syntax-dynamic-import',
42 | isTestEnv && 'babel-plugin-dynamic-import-node',
43 | '@babel/plugin-transform-destructuring',
44 | [
45 | '@babel/plugin-proposal-class-properties',
46 | {
47 | loose: true
48 | }
49 | ],
50 | [
51 | '@babel/plugin-proposal-object-rest-spread',
52 | {
53 | useBuiltIns: true
54 | }
55 | ],
56 | [
57 | '@babel/plugin-transform-runtime',
58 | {
59 | helpers: false,
60 | regenerator: true,
61 | corejs: false
62 | }
63 | ],
64 | [
65 | '@babel/plugin-transform-regenerator',
66 | {
67 | async: false
68 | }
69 | ]
70 | ].filter(Boolean)
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/config/initializers/new_framework_defaults_5_2.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains migration options to ease your Rails 5.2 upgrade.
4 | #
5 | # Once upgraded flip defaults one by one to migrate to the new default.
6 | #
7 | # Read the Guide for Upgrading Ruby on Rails for more info on each option.
8 |
9 | # Make Active Record use stable #cache_key alongside new #cache_version method.
10 | # This is needed for recyclable cache keys.
11 | # Rails.application.config.active_record.cache_versioning = true
12 |
13 | # Use AES-256-GCM authenticated encryption for encrypted cookies.
14 | # Also, embed cookie expiry in signed or encrypted cookies for increased security.
15 | #
16 | # This option is not backwards compatible with earlier Rails versions.
17 | # It's best enabled when your entire app is migrated and stable on 5.2.
18 | #
19 | # Existing cookies will be converted on read then written with the new scheme.
20 | # Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true
21 |
22 | # Use AES-256-GCM authenticated encryption as default cipher for encrypting messages
23 | # instead of AES-256-CBC, when use_authenticated_message_encryption is set to true.
24 | # Rails.application.config.active_support.use_authenticated_message_encryption = true
25 |
26 | # Add default protection from forgery to ActionController::Base instead of in
27 | # ApplicationController.
28 | # Rails.application.config.action_controller.default_protect_from_forgery = true
29 |
30 | # Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and
31 | # 'f' after migrating old data.
32 | # Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
33 |
34 | # Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header.
35 | # Rails.application.config.active_support.use_sha1_digests = true
36 |
37 | # Make `form_with` generate id attributes for any generated HTML tags.
38 | # Rails.application.config.action_view.form_with_generates_ids = true
39 |
--------------------------------------------------------------------------------
/config/webpacker.yml:
--------------------------------------------------------------------------------
1 | # Note: You must restart bin/webpack-dev-server for changes to take effect
2 |
3 | default: &default
4 | source_path: app/javascript
5 | source_entry_path: packs
6 | public_root_path: public
7 | public_output_path: packs
8 | cache_path: tmp/cache/webpacker
9 | check_yarn_integrity: false
10 | webpack_compile_output: true
11 |
12 | # Additional paths webpack should lookup modules
13 | # ['app/assets', 'engine/foo/app/assets']
14 | resolved_paths: []
15 |
16 | # Reload manifest.json on all requests so we reload latest compiled packs
17 | cache_manifest: false
18 |
19 | # Extract and emit a css file
20 | extract_css: false
21 |
22 | static_assets_extensions:
23 | - .jpg
24 | - .jpeg
25 | - .png
26 | - .gif
27 | - .tiff
28 | - .ico
29 | - .svg
30 | - .eot
31 | - .otf
32 | - .ttf
33 | - .woff
34 | - .woff2
35 |
36 | extensions:
37 | - .mjs
38 | - .js
39 | - .sass
40 | - .scss
41 | - .css
42 | - .module.sass
43 | - .module.scss
44 | - .module.css
45 | - .png
46 | - .svg
47 | - .gif
48 | - .jpeg
49 | - .jpg
50 |
51 | development:
52 | <<: *default
53 | compile: true
54 |
55 | # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
56 | check_yarn_integrity: true
57 |
58 | # Reference: https://webpack.js.org/configuration/dev-server/
59 | dev_server:
60 | https: false
61 | host: localhost
62 | port: 3035
63 | public: localhost:3035
64 | hmr: false
65 | # Inline should be set to true if using HMR
66 | inline: true
67 | overlay: true
68 | compress: true
69 | disable_host_check: true
70 | use_local_ip: false
71 | quiet: false
72 | pretty: false
73 | headers:
74 | 'Access-Control-Allow-Origin': '*'
75 | watch_options:
76 | ignored: '**/node_modules/**'
77 |
78 |
79 | test:
80 | <<: *default
81 | compile: true
82 |
83 | # Compile test packs to a separate directory
84 | public_output_path: packs-test
85 |
86 | production:
87 | <<: *default
88 |
89 | # Production depends on precompilation of packs prior to booting for performance.
90 | compile: false
91 |
92 | # Extract and emit a css file
93 | extract_css: true
94 |
95 | # Cache manifest.json for performance
96 | cache_manifest: true
97 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Rails Template
5 | <%= csrf_meta_tags %>
6 | <%= csp_meta_tag %>
7 |
8 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9 | <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
10 |
11 |
12 |
13 |
14 |
52 |
53 |
54 |
55 |
<%= notice %>
56 |
<%= alert %>
57 |
58 | <%= yield %>
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/config/initializers/new_framework_defaults_6_0.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains migration options to ease your Rails 6.0 upgrade.
4 | #
5 | # Once upgraded flip defaults one by one to migrate to the new default.
6 | #
7 | # Read the Guide for Upgrading Ruby on Rails for more info on each option.
8 |
9 | # Don't force requests from old versions of IE to be UTF-8 encoded.
10 | # Rails.application.config.action_view.default_enforce_utf8 = false
11 |
12 | # Embed purpose and expiry metadata inside signed and encrypted
13 | # cookies for increased security.
14 | #
15 | # This option is not backwards compatible with earlier Rails versions.
16 | # It's best enabled when your entire app is migrated and stable on 6.0.
17 | # Rails.application.config.action_dispatch.use_cookies_with_metadata = true
18 |
19 | # Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification.
20 | # Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
21 |
22 | # Return false instead of self when enqueuing is aborted from a callback.
23 | # Rails.application.config.active_job.return_false_on_aborted_enqueue = true
24 |
25 | # Send Active Storage analysis and purge jobs to dedicated queues.
26 | # Rails.application.config.active_storage.queues.analysis = :active_storage_analysis
27 | # Rails.application.config.active_storage.queues.purge = :active_storage_purge
28 |
29 | # When assigning to a collection of attachments declared via `has_many_attached`, replace existing
30 | # attachments instead of appending. Use #attach to add new attachments without replacing existing ones.
31 | # Rails.application.config.active_storage.replace_on_assign_to_many = true
32 |
33 | # Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail.
34 | #
35 | # The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob),
36 | # will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions.
37 | # If you send mail in the background, job workers need to have a copy of
38 | # MailDeliveryJob to ensure all delivery jobs are processed properly.
39 | # Make sure your entire app is migrated and stable on 6.0 before using this setting.
40 | # Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
41 |
42 | # Enable the same cache key to be reused when the object being cached of type
43 | # `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count)
44 | # of the relation's cache key into the cache version to support recycling cache key.
45 | # Rails.application.config.active_record.collection_cache_versioning = true
46 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # This file is the source Rails uses to define your schema when running `rails
6 | # db:schema:load`. When creating a new database, `rails db:schema:load` tends to
7 | # be faster and is potentially less error prone than running all of your
8 | # migrations from scratch. Old migrations may fail to apply correctly if those
9 | # migrations use external dependencies or application code.
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 2019_12_31_214925) do
14 |
15 | # These are extensions that must be enabled in order to support this database
16 | enable_extension "plpgsql"
17 |
18 | create_table "active_admin_comments", force: :cascade do |t|
19 | t.string "namespace"
20 | t.text "body"
21 | t.string "resource_type"
22 | t.bigint "resource_id"
23 | t.string "author_type"
24 | t.bigint "author_id"
25 | t.datetime "created_at", null: false
26 | t.datetime "updated_at", null: false
27 | t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id"
28 | t.index ["namespace"], name: "index_active_admin_comments_on_namespace"
29 | t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id"
30 | end
31 |
32 | create_table "flipper_features", force: :cascade do |t|
33 | t.string "key", null: false
34 | t.datetime "created_at", null: false
35 | t.datetime "updated_at", null: false
36 | t.index ["key"], name: "index_flipper_features_on_key", unique: true
37 | end
38 |
39 | create_table "flipper_gates", force: :cascade do |t|
40 | t.string "feature_key", null: false
41 | t.string "key", null: false
42 | t.string "value"
43 | t.datetime "created_at", null: false
44 | t.datetime "updated_at", null: false
45 | t.index ["feature_key", "key", "value"], name: "index_flipper_gates_on_feature_key_and_key_and_value", unique: true
46 | end
47 |
48 | create_table "users", force: :cascade do |t|
49 | t.string "email", default: "", null: false
50 | t.string "encrypted_password", default: "", null: false
51 | t.string "reset_password_token"
52 | t.datetime "reset_password_sent_at"
53 | t.datetime "remember_created_at"
54 | t.datetime "created_at", null: false
55 | t.datetime "updated_at", null: false
56 | t.boolean "admin", default: false
57 | t.index ["email"], name: "index_users_on_email", unique: true
58 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
59 | end
60 |
61 | end
62 |
--------------------------------------------------------------------------------
/spec/rails_helper.rb:
--------------------------------------------------------------------------------
1 | # This file is copied to spec/ when you run 'rails generate rspec:install'
2 | require 'spec_helper'
3 | ENV['RAILS_ENV'] ||= 'test'
4 | require File.expand_path('../config/environment', __dir__)
5 | # Prevent database truncation if the environment is production
6 | abort('The Rails environment is running in production mode!') if Rails.env.production?
7 | require 'rspec/rails'
8 |
9 | # Add additional requires below this line. Rails is not loaded until this point!
10 | require 'shoulda/matchers'
11 | require 'support/factory_bot'
12 | require 'support/database_cleaner'
13 | require 'support/shoulda_matchers'
14 |
15 | # Requires supporting ruby files with custom matchers and macros, etc, in
16 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
17 | # run as spec files by default. This means that files in spec/support that end
18 | # in _spec.rb will both be required and run as specs, causing the specs to be
19 | # run twice. It is recommended that you do not name files matching this glob to
20 | # end with _spec.rb. You can configure this pattern with the --pattern
21 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
22 | #
23 | # The following line is provided for convenience purposes. It has the downside
24 | # of increasing the boot-up time by auto-requiring all files in the support
25 | # directory. Alternatively, in the individual `*_spec.rb` files, manually
26 | # require only the support files necessary.
27 | #
28 | # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
29 |
30 | # Checks for pending migrations and applies them before tests are run.
31 | # If you are not using ActiveRecord, you can remove these lines.
32 | begin
33 | ActiveRecord::Migration.maintain_test_schema!
34 | rescue ActiveRecord::PendingMigrationError => e
35 | puts e.to_s.strip
36 | exit 1
37 | end
38 |
39 | RSpec.configure do |config|
40 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
41 | config.fixture_path = "#{::Rails.root}/spec/fixtures"
42 |
43 | # If you're not using ActiveRecord, or you'd prefer not to run each of your
44 | # examples within a transaction, remove the following line or assign false
45 | # instead of true.
46 |
47 | # disabled because we use database_cleaner
48 | # https://www.sitepoint.com/learn-the-first-best-practices-for-rails-and-rspec/
49 | config.use_transactional_fixtures = false
50 |
51 | # RSpec Rails can automatically mix in different behaviours to your tests
52 | # based on their file location, for example enabling you to call `get` and
53 | # `post` in specs under `spec/controllers`.
54 | #
55 | # You can disable this behaviour by removing the line below, and instead
56 | # explicitly tag your specs with their type, e.g.:
57 | #
58 | # RSpec.describe UsersController, :type => :controller do
59 | # # ...
60 | # end
61 | #
62 | # The different available types are documented in the features, such as in
63 | # https://relishapp.com/rspec/rspec-rails/docs
64 | config.infer_spec_type_from_file_location!
65 |
66 | # Filter lines from Rails gems in backtraces.
67 | config.filter_rails_from_backtrace!
68 | # arbitrary gems may also be filtered via:
69 | # config.filter_gems_from_backtrace("gem name")
70 | end
71 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # for gem `rack-livereload` https://github.com/onesupercoder/rack-livereload
5 | config.middleware.insert_after ActionDispatch::Static, Rack::LiveReload
6 |
7 | # In the development environment your application's code is reloaded on
8 | # every request. This slows down response time but is perfect for development
9 | # since you don't have to restart the web server when you make code changes.
10 | config.cache_classes = false
11 |
12 | # Do not eager load code on boot.
13 | config.eager_load = false
14 |
15 | # Show full error reports.
16 | config.consider_all_requests_local = true
17 |
18 | # Enable/disable caching. By default caching is disabled.
19 | # Run rails dev:cache to toggle caching.
20 | if Rails.root.join('tmp', 'caching-dev.txt').exist?
21 | config.action_controller.perform_caching = true
22 | config.action_controller.enable_fragment_cache_logging = true
23 |
24 | config.cache_store = :memory_store
25 | config.public_file_server.headers = {
26 | 'Cache-Control' => "public, max-age=#{2.days.to_i}"
27 | }
28 | else
29 | config.action_controller.perform_caching = false
30 |
31 | config.cache_store = :null_store
32 | end
33 |
34 | # Store uploaded files on the local file system (see config/storage.yml for options).
35 | config.active_storage.service = :local
36 |
37 | # Don't care if the mailer can't send.
38 | config.action_mailer.raise_delivery_errors = false
39 |
40 | config.action_mailer.perform_caching = false
41 |
42 | # Print deprecation notices to the Rails logger.
43 | config.active_support.deprecation = :log
44 |
45 | # Raise an error on page load if there are pending migrations.
46 | config.active_record.migration_error = :page_load
47 |
48 | # Highlight code that triggered database queries in logs.
49 | config.active_record.verbose_query_logs = true
50 |
51 | # Debug mode disables concatenation and preprocessing of assets.
52 | # This option may cause significant delays in view rendering with a large
53 | # number of complex assets.
54 | config.assets.debug = true
55 |
56 | # Suppress logger output for asset requests.
57 | config.assets.quiet = true
58 |
59 | # Raises error for missing translations.
60 | config.action_view.raise_on_missing_translations = true
61 |
62 | # Use an evented file watcher to asynchronously detect changes in source code,
63 | # routes, locales, etc. This feature depends on the listen gem.
64 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
65 |
66 | # Email config
67 | config.action_mailer.raise_delivery_errors = true
68 | config.action_mailer.perform_caching = false
69 | config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
70 | config.action_mailer.delivery_method = :smtp
71 | config.action_mailer.perform_deliveries = true
72 |
73 | # EMAIL SMTP
74 | config.action_mailer.smtp_settings = {
75 | user_name: Rails.application.credentials.email[:user_name],
76 | password: Rails.application.credentials.email[:password],
77 | address: Rails.application.credentials.email[:host],
78 | port: 587,
79 | enable_starttls_auto: true,
80 | format: :html,
81 | from: 'mail@rails-template.heroku.com'
82 | }
83 | end
84 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # PostgreSQL. Versions 9.1 and up are supported.
2 | #
3 | # Install the pg driver:
4 | # gem install pg
5 | # On OS X with Homebrew:
6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7 | # On OS X with MacPorts:
8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9 | # On Windows:
10 | # gem install pg
11 | # Choose the win32 build.
12 | # Install PostgreSQL and put its /bin directory on your path.
13 | #
14 | # Configure Using Gemfile
15 | # gem 'pg'
16 | #
17 | default: &default
18 | adapter: postgresql
19 | encoding: unicode
20 | # For details on connection pooling, see Rails configuration guide
21 | # http://guides.rubyonrails.org/configuring.html#database-pooling
22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23 |
24 | development:
25 | <<: *default
26 | database: rails-template_development
27 |
28 | # The specified database role being used to connect to postgres.
29 | # To create additional roles in postgres see `$ createuser --help`.
30 | # When left blank, postgres will use the default role. This is
31 | # the same name as the operating system user that initialized the database.
32 | #username: rails-template
33 |
34 | # The password associated with the postgres role (username).
35 | #password:
36 |
37 | # Connect on a TCP socket. Omitted by default since the client uses a
38 | # domain socket that doesn't need configuration. Windows does not have
39 | # domain sockets, so uncomment these lines.
40 | #host: localhost
41 |
42 | # The TCP port the server listens on. Defaults to 5432.
43 | # If your server runs on a different port number, change accordingly.
44 | #port: 5432
45 |
46 | # Schema search path. The server defaults to $user,public
47 | #schema_search_path: myapp,sharedapp,public
48 |
49 | # Minimum log levels, in increasing order:
50 | # debug5, debug4, debug3, debug2, debug1,
51 | # log, notice, warning, error, fatal, and panic
52 | # Defaults to warning.
53 | #min_messages: notice
54 |
55 | # Warning: The database defined as "test" will be erased and
56 | # re-generated from your development database when you run "rake".
57 | # Do not set this db to the same as development or production.
58 | test:
59 | <<: *default
60 | database: rails-template_test
61 |
62 | # As with config/secrets.yml, you never want to store sensitive information,
63 | # like your database password, in your source code. If your source code is
64 | # ever seen by anyone, they now have access to your database.
65 | #
66 | # Instead, provide the password as a unix environment variable when you boot
67 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
68 | # for a full rundown on how to provide these environment variables in a
69 | # production deployment.
70 | #
71 | # On Heroku and other platform providers, you may have a full connection URL
72 | # available as an environment variable. For example:
73 | #
74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
75 | #
76 | # You can use this database configuration with:
77 | #
78 | # production:
79 | # url: <%= ENV['DATABASE_URL'] %>
80 | #
81 | production:
82 | <<: *default
83 | url: <%= ENV['DATABASE_URL'] %>
84 | # database: rails-template_production
85 | # username: rails-template
86 | # password: <%= ENV['RAILS_5_BOILERPLATE_DATABASE_PASSWORD'] %>
87 |
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 |
3 | defaults: &defaults
4 | working_directory: ~/repo
5 | docker:
6 | - image: cimg/ruby:2.7.4-browsers
7 | environment:
8 | JOBS: 2
9 | RAILS_ENV: test
10 | PGHOST: 127.0.0.1
11 | PGUSER: root
12 | LOCAL_TEST_DB_NAME: circle-ci_test
13 | DATABASE_URL: "postgres://root@localhost:5432/circle-ci_test"
14 | - image: cimg/postgres:10.18
15 | environment:
16 | POSTGRES_USER: root
17 | POSTGRES_PASSWORD: password
18 | POSTGRES_DB: circle-ci_test
19 |
20 | jobs:
21 | setup-code-coverage:
22 | <<: *defaults
23 | steps:
24 | - run:
25 | name: Download CodeClimate Reporter
26 | command: |
27 | mkdir -p tmp/
28 | curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
29 | chmod +x ./tmp/cc-test-reporter
30 | - persist_to_workspace:
31 | root: tmp
32 | paths:
33 | - cc-test-reporter
34 | rails:
35 | <<: *defaults
36 | steps:
37 | - checkout
38 | - attach_workspace:
39 | at: ~/repo/tmp
40 | - restore_cache:
41 | keys:
42 | - rails-template-{{ checksum "Gemfile.lock" }}
43 | - rails-template-
44 | - run:
45 | name: Install dependencies
46 | command: |
47 | gem install bundler -v $(cat Gemfile.lock | tail -1 | tr -d ' ')
48 | bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs 4 --retry 3
49 | - save_cache:
50 | key: rails-template-{{ checksum "Gemfile.lock" }}
51 | paths:
52 | - ./vendor/bundle
53 | - run:
54 | name: Database Setup
55 | command: |
56 | bundle exec rails db:create db:schema:load --trace
57 | bundle exec rake db:migrate
58 | - run:
59 | name: Run Brakeman
60 | command: |
61 | sudo mkdir /brakeman && bundle update brakeman --quiet
62 | mkdir -p $CIRCLE_TEST_REPORTS/brakeman
63 | bundle exec brakeman --exit-on-warn
64 | - run:
65 | name: Run Rubopcop
66 | command: |
67 | sudo mkdir /rubocop && bundle update rubocop --quiet
68 | mkdir -p $CIRCLE_TEST_REPORTS/rubocop
69 | bundle exec rubocop --fail-fast --fail-level E
70 | - run:
71 | name: Run Tests
72 | command: |
73 | bundle exec rspec
74 | - run:
75 | name: Format Coverage Data
76 | command: |
77 | ./tmp/cc-test-reporter format-coverage --debug -t simplecov -o tmp/codeclimate.rails-template.json ./rails-template/coverage/.resultset.json
78 | - persist_to_workspace:
79 | root: tmp
80 | paths:
81 | - codeclimate.rails-template.json
82 | send-code-coverage:
83 | <<: *defaults
84 | steps:
85 | - checkout
86 | - attach_workspace:
87 | at: ~/repo/tmp
88 | - run:
89 | name: Send to CodeClimate
90 | command: |
91 | ./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json -o tmp/codeclimate.total.json
92 | ./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.total.json
93 |
94 | workflows:
95 | version: 2
96 | run_tests:
97 | jobs:
98 | - setup-code-coverage
99 | - rails:
100 | requires:
101 | - setup-code-coverage
102 | - send-code-coverage:
103 | requires:
104 | - rails
105 |
106 |
--------------------------------------------------------------------------------
/app/views/home/index.html.erb:
--------------------------------------------------------------------------------
1 |
9 |
86 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3 |
4 | ruby '2.7.4'
5 |
6 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
7 | gem 'rails', '~> 6.0.3.6'
8 |
9 | gem 'bundler', '2.2.25'
10 | # Use sqlite3 as the database for Active Record
11 | # gem 'sqlite3', '~> 1.4'
12 | # Use postgresql as the database for Active Record instead of sqlite3 for consistency with production
13 | gem 'pg', '>= 0.18', '< 2.0'
14 | # Use Puma as the app server
15 | gem 'puma', '~> 4.3'
16 | # Use SCSS for stylesheets
17 | gem 'sass-rails', '>= 6'
18 | # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
19 | gem 'webpacker', '~> 4.0'
20 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
21 | gem 'turbolinks', '~> 5'
22 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
23 | gem 'jbuilder', '~> 2.7'
24 | # Use Redis adapter to run Action Cable in production
25 | # gem 'redis', '~> 4.0'
26 | # Use Active Model has_secure_password
27 | # gem 'bcrypt', '~> 3.1.7'
28 |
29 | # Use Active Storage variant
30 | # gem 'image_processing', '~> 1.2'
31 |
32 | # Reduces boot times through caching; required in config/boot.rb
33 | gem 'bootsnap', '>= 1.4.2', require: false
34 |
35 | group :development, :test do
36 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console
37 | gem 'byebug', platforms: ['mri', 'mingw', 'x64_mingw']
38 | # Environment Variable loading https://github.com/bkeepers/dotenv
39 | gem 'dotenv-rails'
40 | # Stubbing for rails model https://github.com/thoughtbot/factory_bot_rails
41 | gem 'factory_bot_rails', '~> 4.11'
42 | # RSpec Testing https://github.com/rspec/rspec-rails
43 | gem 'rspec-rails', '4.0.0.beta3'
44 | # Ruby static linting https://github.com/rubocop-hq/rubocop
45 | gem 'rubocop', '~> 0.78', require: false
46 | # RSpec extension https://github.com/rubocop-hq/rubocop-rspec
47 | gem 'rubocop-rspec', '~> 1.25'
48 | end
49 |
50 | group :development do
51 | # Security static analysis https://github.com/presidentbeef/brakeman
52 | gem 'brakeman'
53 | # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
54 | gem 'listen', '>= 3.0.5', '< 3.2'
55 | gem 'web-console', '>= 3.3.0'
56 | # Live reloading for development https://github.com/guard/guard
57 | gem 'guard'
58 | gem 'guard-brakeman'
59 | gem 'guard-livereload', '~> 2.5', require: false
60 | gem 'guard-rails', require: false
61 | gem 'guard-rspec', require: false
62 | gem 'guard-spring'
63 | gem 'rack-livereload'
64 | # Load IRB for debugging https://github.com/rweng/pry-rails
65 | gem 'pry-rails'
66 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
67 | gem 'spring'
68 | gem 'spring-commands-rspec'
69 | gem 'spring-commands-rubocop'
70 | gem 'spring-watcher-listen', '~> 2.0.0'
71 | end
72 |
73 | group :test do
74 | # Adds support for Capybara system testing and selenium driver
75 | gem 'capybara', '>= 2.15'
76 | gem 'selenium-webdriver'
77 | # Easy installation and use of chromedriver to run system tests with Chrome
78 | gem 'webdrivers'
79 | # Empty database between tests https://github.com/DatabaseCleaner/database_cleaner
80 | gem 'database_cleaner'
81 | gem 'rails-controller-testing'
82 | # Awesome DSL for writing tests https://github.com/thoughtbot/shoulda-matchers
83 | gem 'shoulda-matchers', '4.0.0.rc1'
84 | # Code Coverage reporting & UI https://github.com/colszowka/simplecov
85 | gem 'simplecov', '< 0.18', require: false
86 | end
87 |
88 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
89 | gem 'tzinfo-data', platforms: ['mingw', 'mswin', 'x64_mingw', 'jruby']
90 |
91 | # Basic user Auth https://github.com/plataformatec/devise
92 | gem 'devise', '>= 4.7.1'
93 | # Fake data generation https://github.com/stympy/faker
94 | gem 'faker', '~> 1.9'
95 | # Feature switch management & UI https://github.com/jnunemaker/flipper
96 | gem 'flipper'
97 | gem 'flipper-active_record'
98 | gem 'flipper-ui'
99 |
100 | # UI Gems
101 | # Admin UI https://github.com/activeadmin/activeadmin
102 | gem 'activeadmin'
103 | # Include bootstrap 4 https://github.com/twbs/bootstrap-rubygem
104 | gem 'bootstrap', '~> 4.3.1'
105 | # Required for bootstrap jquery functionality
106 | gem 'jquery-rails'
107 | # Enable Translations of Devise views gem 'devise-i18n'
108 | # Must be before devise-bootstrap-views https://github.com/hisea/devise-bootstrap-views/issues/55
109 | gem 'devise-i18n'
110 | # Generate devise views with bootstrap https://github.com/hisea/devise-bootstrap-views
111 | gem 'devise-bootstrap-views', '~> 1.0'
112 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # added based on https://www.sitepoint.com/learn-the-first-best-practices-for-rails-and-rspec/
2 | require 'capybara/rspec'
3 | require 'simplecov'
4 |
5 | SimpleCov.start
6 |
7 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
8 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
9 | # The generated `.rspec` file contains `--require spec_helper` which will cause
10 | # this file to always be loaded, without a need to explicitly require it in any
11 | # files.
12 | #
13 | # Given that it is always loaded, you are encouraged to keep this file as
14 | # light-weight as possible. Requiring heavyweight dependencies from this file
15 | # will add to the boot time of your test suite on EVERY test run, even for an
16 | # individual file that may not need all of that loaded. Instead, consider making
17 | # a separate helper file that requires the additional dependencies and performs
18 | # the additional setup, and require it from the spec files that actually need
19 | # it.
20 | #
21 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22 | RSpec.configure do |config|
23 | # rspec-expectations config goes here. You can use an alternate
24 | # assertion/expectation library such as wrong or the stdlib/minitest
25 | # assertions if you prefer.
26 | config.expect_with :rspec do |expectations|
27 | # This option will default to `true` in RSpec 4. It makes the `description`
28 | # and `failure_message` of custom matchers include text for helper methods
29 | # defined using `chain`, e.g.:
30 | # be_bigger_than(2).and_smaller_than(4).description
31 | # # => "be bigger than 2 and smaller than 4"
32 | # ...rather than:
33 | # # => "be bigger than 2"
34 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35 | end
36 |
37 | # rspec-mocks config goes here. You can use an alternate test double
38 | # library (such as bogus or mocha) by changing the `mock_with` option here.
39 | config.mock_with :rspec do |mocks|
40 | # Prevents you from mocking or stubbing a method that does not exist on
41 | # a real object. This is generally recommended, and will default to
42 | # `true` in RSpec 4.
43 | mocks.verify_partial_doubles = true
44 | end
45 |
46 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
47 | # have no way to turn it off -- the option exists only for backwards
48 | # compatibility in RSpec 3). It causes shared context metadata to be
49 | # inherited by the metadata hash of host groups and examples, rather than
50 | # triggering implicit auto-inclusion in groups with matching metadata.
51 | config.shared_context_metadata_behavior = :apply_to_host_groups
52 |
53 | # The settings below are suggested to provide a good initial experience
54 | # with RSpec, but feel free to customize to your heart's content.
55 | # # This allows you to limit a spec run to individual examples or groups
56 | # # you care about by tagging them with `:focus` metadata. When nothing
57 | # # is tagged with `:focus`, all examples get run. RSpec also provides
58 | # # aliases for `it`, `describe`, and `context` that include `:focus`
59 | # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
60 | # config.filter_run_when_matching :focus
61 | #
62 | # # Allows RSpec to persist some state between runs in order to support
63 | # # the `--only-failures` and `--next-failure` CLI options. We recommend
64 | # # you configure your source control system to ignore this file.
65 | # config.example_status_persistence_file_path = "spec/examples.txt"
66 | #
67 | # # Limits the available syntax to the non-monkey patched syntax that is
68 | # # recommended. For more details, see:
69 | # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
70 | # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
71 | # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
72 | # config.disable_monkey_patching!
73 | #
74 | # # Many RSpec users commonly either run the entire suite or an individual
75 | # # file, and it's useful to allow more verbose output when running an
76 | # # individual spec file.
77 | # if config.files_to_run.one?
78 | # # Use the documentation formatter for detailed output,
79 | # # unless a formatter has already been configured
80 | # # (e.g. via a command-line flag).
81 | # config.default_formatter = "doc"
82 | # end
83 | #
84 | # # Print the 10 slowest examples and example groups at the
85 | # # end of the spec run, to help surface which specs are running
86 | # # particularly slow.
87 | # config.profile_examples = 10
88 | #
89 | # # Run specs in random order to surface order dependencies. If you find an
90 | # # order dependency and want to debug it, you can fix the order by providing
91 | # # the seed, which is printed after each run.
92 | # # --seed 1234
93 | # config.order = :random
94 | #
95 | # # Seed global randomization in this process using the `--seed` CLI option.
96 | # # Setting this allows you to use `--seed` to deterministically reproduce
97 | # # test failures related to randomization by passing the same `--seed` value
98 | # # as the one that triggered the failure.
99 | # Kernel.srand config.seed
100 | end
101 |
--------------------------------------------------------------------------------
/Guardfile:
--------------------------------------------------------------------------------
1 | # A sample Guardfile
2 | # More info at https://github.com/guard/guard#readme
3 |
4 | ## Uncomment and set this to only include directories you want to watch
5 | # directories %w(app lib config test spec features) \
6 | # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7 |
8 | ## Note: if you are using the `directories` clause above and you are not
9 | ## watching the project directory ('.'), then you will want to move
10 | ## the Guardfile to a watched dir and symlink it back, e.g.
11 | #
12 | # $ mkdir config
13 | # $ mv Guardfile config/
14 | # $ ln -s config/Guardfile .
15 | #
16 | # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17 |
18 | # Guard-Rails supports a lot options with default values:
19 | # daemon: false # runs the server as a daemon.
20 | # debugger: false # enable ruby-debug gem.
21 | # environment: 'development' # changes server environment.
22 | # force_run: false # kills any process that's holding the listen port before attempting to (re)start Rails.
23 | # pid_file: 'tmp/pids/[RAILS_ENV].pid' # specify your pid_file.
24 | # host: 'localhost' # server hostname.
25 | # port: 3000 # server port number.
26 | # root: '/spec/dummy' # Rails' root path.
27 | # server: thin # webserver engine.
28 | # start_on_start: true # will start the server when starting Guard.
29 | # timeout: 30 # waits untill restarting the Rails server, in seconds.
30 | # zeus_plan: server # custom plan in zeus, only works with `zeus: true`.
31 | # zeus: false # enables zeus gem.
32 | # CLI: 'rails server' # customizes runner command. Omits all options except `pid_file`!
33 |
34 | guard 'rails' do
35 | watch('Gemfile.lock')
36 | watch(%r{^(config|lib)/.*})
37 | end
38 |
39 | # Note: The cmd option is now required due to the increasing number of ways
40 | # rspec may be run, below are examples of the most common uses.
41 | # * bundler: 'bundle exec rspec'
42 | # * bundler binstubs: 'bin/rspec'
43 | # * spring: 'bin/rspec' (This will use spring if running and you have
44 | # installed the spring binstubs per the docs)
45 | # * zeus: 'zeus rspec' (requires the server to be started separately)
46 | # * 'just' rspec: 'rspec'
47 |
48 | guard :rspec, cmd: 'spring rspec' do
49 | require 'guard/rspec/dsl'
50 | dsl = Guard::RSpec::Dsl.new(self)
51 |
52 | # Feel free to open issues for suggestions and improvements
53 |
54 | # RSpec files
55 | rspec = dsl.rspec
56 | watch(rspec.spec_helper) { rspec.spec_dir }
57 | watch(rspec.spec_support) { rspec.spec_dir }
58 | watch(rspec.spec_files)
59 |
60 | # Ruby files
61 | ruby = dsl.ruby
62 | dsl.watch_spec_files_for(ruby.lib_files)
63 |
64 | # Rails files
65 | rails = dsl.rails(view_extensions: ['erb', 'haml', 'slim'])
66 | dsl.watch_spec_files_for(rails.app_files)
67 | dsl.watch_spec_files_for(rails.views)
68 |
69 | watch(rails.controllers) do |m|
70 | [
71 | rspec.spec.call("routing/#{m[1]}_routing"),
72 | rspec.spec.call("controllers/#{m[1]}_controller"),
73 | rspec.spec.call("acceptance/#{m[1]}")
74 | ]
75 | end
76 |
77 | # Rails config changes
78 | watch(rails.spec_helper) { rspec.spec_dir }
79 | watch(rails.routes) { "#{rspec.spec_dir}/routing" }
80 | watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
81 |
82 | # Capybara features specs
83 | watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
84 | watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
85 |
86 | # Turnip features and steps
87 | watch(%r{^spec/acceptance/(.+)\.feature$})
88 | watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
89 | Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
90 | end
91 | end
92 |
93 | guard 'livereload' do
94 | extensions = {
95 | css: :css,
96 | scss: :css,
97 | sass: :css,
98 | js: :js,
99 | # coffee: :js, # uncomment if you are ussing CoffeeScript
100 | html: :html,
101 | png: :png,
102 | gif: :gif,
103 | jpg: :jpg,
104 | jpeg: :jpeg
105 | # less: :less, # uncomment if you want LESS stylesheets done in browser
106 | }
107 |
108 | rails_view_exts = ['erb', 'haml', 'slim']
109 |
110 | # file types LiveReload may optimize refresh for
111 | compiled_exts = extensions.values.uniq
112 | watch(%r{public/.+\.(#{compiled_exts * '|'})})
113 |
114 | extensions.each do |ext, type|
115 | watch(%r{
116 | (?:app|vendor)
117 | (?:/assets/\w+/(?[^.]+) # path+base without extension
118 | (?\.#{ext})) # matching extension (must be first encountered)
119 | (?:\.\w+|$) # other extensions
120 | }x) do |m|
121 | path = m[1]
122 | "/assets/#{path}.#{type}"
123 | end
124 | end
125 |
126 | # file needing a full reload of the page anyway
127 | watch(%r{app/views/.+\.(#{rails_view_exts * '|'})$})
128 | watch(%r{app/helpers/.+\.rb})
129 | watch(%r{config/locales/.+\.yml})
130 | end
131 |
132 | guard 'spring', bundler: true do
133 | watch('Gemfile.lock')
134 | watch(%r{^config/})
135 | watch(%r{^spec/(support|factories)/})
136 | watch(%r{^spec/factory.rb})
137 | end
138 |
139 | guard 'brakeman', run_on_start: true do
140 | watch(%r{^app/.+\.(erb|haml|rhtml|rb)$})
141 | watch(%r{^config/.+\.rb$})
142 | watch(%r{^lib/.+\.rb$})
143 | watch('Gemfile')
144 | end
145 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
18 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
19 | # config.require_master_key = true
20 |
21 | # Disable serving static files from the `/public` folder by default since
22 | # Apache or NGINX already handles this.
23 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
24 |
25 | # Compress CSS using a preprocessor.
26 | # config.assets.css_compressor = :sass
27 |
28 | # Do not fallback to assets pipeline if a precompiled asset is missed.
29 | config.assets.compile = false
30 |
31 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
32 | # config.action_controller.asset_host = 'http://assets.example.com'
33 |
34 | # Specifies the header that your server uses for sending files.
35 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
36 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
37 |
38 | # Store uploaded files on the local file system (see config/storage.yml for options).
39 | config.active_storage.service = :local
40 |
41 | # Mount Action Cable outside main process or domain.
42 | # config.action_cable.mount_path = nil
43 | # config.action_cable.url = 'wss://example.com/cable'
44 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
45 |
46 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
47 | # config.force_ssl = true
48 |
49 | # Use the lowest log level to ensure availability of diagnostic information
50 | # when problems arise.
51 | config.log_level = :debug
52 |
53 | # Prepend all log lines with the following tags.
54 | config.log_tags = [ :request_id ]
55 |
56 | # Use a different cache store in production.
57 | # config.cache_store = :mem_cache_store
58 |
59 | # Use a real queuing backend for Active Job (and separate queues per environment).
60 | # config.active_job.queue_adapter = :resque
61 | # config.active_job.queue_name_prefix = "rails_template_production"
62 |
63 | config.action_mailer.perform_caching = false
64 |
65 | # Ignore bad email addresses and do not raise email delivery errors.
66 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
67 | # config.action_mailer.raise_delivery_errors = false
68 |
69 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
70 | # the I18n.default_locale when a translation cannot be found).
71 | config.i18n.fallbacks = true
72 |
73 | # Send deprecation notices to registered listeners.
74 | config.active_support.deprecation = :notify
75 |
76 | # Use default logging formatter so that PID and timestamp are not suppressed.
77 | config.log_formatter = ::Logger::Formatter.new
78 |
79 | # Use a different logger for distributed setups.
80 | # require 'syslog/logger'
81 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
82 |
83 | if ENV['RAILS_LOG_TO_STDOUT'].present?
84 | logger = ActiveSupport::Logger.new(STDOUT)
85 | logger.formatter = config.log_formatter
86 | config.logger = ActiveSupport::TaggedLogging.new(logger)
87 | end
88 |
89 | # Do not dump schema after migrations.
90 | config.active_record.dump_schema_after_migration = false
91 |
92 | # Inserts middleware to perform automatic connection switching.
93 | # The `database_selector` hash is used to pass options to the DatabaseSelector
94 | # middleware. The `delay` is used to determine how long to wait after a write
95 | # to send a subsequent read to the primary.
96 | #
97 | # The `database_resolver` class is used by the middleware to determine which
98 | # database is appropriate to use based on the time delay.
99 | #
100 | # The `database_resolver_context` class is used by the middleware to set
101 | # timestamps for the last write to the primary. The resolver uses the context
102 | # class timestamps to determine how long to wait before reading from the
103 | # replica.
104 | #
105 | # By default Rails will store a last write timestamp in the session. The
106 | # DatabaseSelector middleware is designed as such you can define your own
107 | # strategy for connection switching and pass that into the middleware through
108 | # these configuration options.
109 | # config.active_record.database_selector = { delay: 2.seconds }
110 | # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
111 | # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
112 |
113 | # Email Config
114 |
115 | config.action_mailer.delivery_method = :smtp
116 | config.action_mailer.perform_deliveries = true
117 |
118 | # EMAIL SMTP
119 | config.action_mailer.smtp_settings = {
120 | user_name: Rails.application.credentials.email[:user_name],
121 | password: Rails.application.credentials.email[:password],
122 | address: Rails.application.credentials.email[:host],
123 | port: 587,
124 | enable_starttls_auto: true,
125 | format: :html,
126 | from: 'mail@rails-template.heroku.com'
127 | }
128 | end
129 |
--------------------------------------------------------------------------------
/config/initializers/active_admin.rb:
--------------------------------------------------------------------------------
1 | ActiveAdmin.setup do |config|
2 | # == Site Title
3 | #
4 | # Set the title that is displayed on the main layout
5 | # for each of the active admin pages.
6 | #
7 | config.site_title = 'Rails Template'
8 |
9 | # Set the link url for the title. For example, to take
10 | # users to your main site. Defaults to no link.
11 | #
12 | # config.site_title_link = '/'
13 |
14 | # Set an optional image to be displayed for the header
15 | # instead of a string (overrides :site_title)
16 | #
17 | # Note: Aim for an image that's 21px high so it fits in the header.
18 | #
19 | # config.site_title_image = 'logo.png'
20 |
21 | # == Default Namespace
22 | #
23 | # Set the default namespace each administration resource
24 | # will be added to.
25 | #
26 | # eg:
27 | # config.default_namespace = :hello_world
28 | #
29 | # This will create resources in the HelloWorld module and
30 | # will namespace routes to /hello_world/*
31 | #
32 | # To set no namespace by default, use:
33 | # config.default_namespace = false
34 | #
35 | # Default:
36 | # config.default_namespace = :admin
37 | #
38 | # You can customize the settings for each namespace by using
39 | # a namespace block. For example, to change the site title
40 | # within a namespace:
41 | #
42 | # config.namespace :admin do |admin|
43 | # admin.site_title = 'Custom Admin Title'
44 | # end
45 | #
46 | # This will ONLY change the title for the admin section. Other
47 | # namespaces will continue to use the main 'site_title' configuration.
48 |
49 | # == User Authentication
50 | #
51 | # Active Admin will automatically call an authentication
52 | # method in a before filter of all controller actions to
53 | # ensure that there is a currently logged in admin user.
54 | #
55 | # This setting changes the method which Active Admin calls
56 | # within the application controller.
57 | config.authentication_method = :authenticate_admin!
58 |
59 | # == User Authorization
60 | #
61 | # Active Admin will automatically call an authorization
62 | # method in a before filter of all controller actions to
63 | # ensure that there is a user with proper rights. You can use
64 | # CanCanAdapter or make your own. Please refer to documentation.
65 | # config.authorization_adapter = ActiveAdmin::CanCanAdapter
66 |
67 | # In case you prefer Pundit over other solutions you can here pass
68 | # the name of default policy class. This policy will be used in every
69 | # case when Pundit is unable to find suitable policy.
70 | # config.pundit_default_policy = 'MyDefaultPunditPolicy'
71 |
72 | # If you wish to maintain a separate set of Pundit policies for admin
73 | # resources, you may set a namespace here that Pundit will search
74 | # within when looking for a resource's policy.
75 | # config.pundit_policy_namespace = :admin
76 |
77 | # You can customize your CanCan Ability class name here.
78 | # config.cancan_ability_class = 'Ability'
79 |
80 | # You can specify a method to be called on unauthorized access.
81 | # This is necessary in order to prevent a redirect loop which happens
82 | # because, by default, user gets redirected to Dashboard. If user
83 | # doesn't have access to Dashboard, he'll end up in a redirect loop.
84 | # Method provided here should be defined in application_controller.rb.
85 | # config.on_unauthorized_access = :access_denied
86 |
87 | # == Current User
88 | #
89 | # Active Admin will associate actions with the current
90 | # user performing them.
91 | #
92 | # This setting changes the method which Active Admin calls
93 | # (within the application controller) to return the currently logged in user.
94 | config.current_user_method = :current_user
95 |
96 | # == Logging Out
97 | #
98 | # Active Admin displays a logout link on each screen. These
99 | # settings configure the location and method used for the link.
100 | #
101 | # This setting changes the path where the link points to. If it's
102 | # a string, the strings is used as the path. If it's a Symbol, we
103 | # will call the method to return the path.
104 | #
105 | # Default:
106 | config.logout_link_path = :destroy_user_session_path
107 |
108 | # This setting changes the http method used when rendering the
109 | # link. For example :get, :delete, :put, etc..
110 | #
111 | # Default:
112 | # config.logout_link_method = :get
113 |
114 | # == Root
115 | #
116 | # Set the action to call for the root path. You can set different
117 | # roots for each namespace.
118 | #
119 | # Default:
120 | # config.root_to = 'dashboard#index'
121 |
122 | # == Admin Comments
123 | #
124 | # This allows your users to comment on any resource registered with Active Admin.
125 | #
126 | # You can completely disable comments:
127 | # config.comments = false
128 | #
129 | # You can change the name under which comments are registered:
130 | # config.comments_registration_name = 'AdminComment'
131 | #
132 | # You can change the order for the comments and you can change the column
133 | # to be used for ordering:
134 | # config.comments_order = 'created_at ASC'
135 | #
136 | # You can disable the menu item for the comments index page:
137 | # config.comments_menu = false
138 | #
139 | # You can customize the comment menu:
140 | # config.comments_menu = { parent: 'Admin', priority: 1 }
141 |
142 | # == Batch Actions
143 | #
144 | # Enable and disable Batch Actions
145 | #
146 | config.batch_actions = true
147 |
148 | # == Controller Filters
149 | #
150 | # You can add before, after and around filters to all of your
151 | # Active Admin resources and pages from here.
152 | #
153 | # config.before_action :do_something_awesome
154 |
155 | # == Attribute Filters
156 | #
157 | # You can exclude possibly sensitive model attributes from being displayed,
158 | # added to forms, or exported by default by ActiveAdmin
159 | #
160 | config.filter_attributes = [
161 | :encrypted_password,
162 | :password,
163 | :password_confirmation
164 | ]
165 |
166 | # == Localize Date/Time Format
167 | #
168 | # Set the localize format to display dates and times.
169 | # To understand how to localize your app with I18n, read more at
170 | # https://guides.rubyonrails.org/i18n.html
171 | #
172 | # You can run `bin/rails runner 'puts I18n.t('date.formats')'` to see the
173 | # available formats in your application.
174 | #
175 | config.localize_format = :long
176 |
177 | # == Setting a Favicon
178 | #
179 | # config.favicon = 'favicon.ico'
180 |
181 | # == Meta Tags
182 | #
183 | # Add additional meta tags to the head element of active admin pages.
184 | #
185 | # Add tags to all pages logged in users see:
186 | # config.meta_tags = { author: 'My Company' }
187 |
188 | # By default, sign up/sign in/recover password pages are excluded
189 | # from showing up in search engine results by adding a robots meta
190 | # tag. You can reset the hash of meta tags included in logged out
191 | # pages:
192 | # config.meta_tags_for_logged_out_pages = {}
193 |
194 | # == Removing Breadcrumbs
195 | #
196 | # Breadcrumbs are enabled by default. You can customize them for individual
197 | # resources or you can disable them globally from here.
198 | #
199 | # config.breadcrumb = false
200 |
201 | # == Create Another Checkbox
202 | #
203 | # Create another checkbox is disabled by default. You can customize it for individual
204 | # resources or you can enable them globally from here.
205 | #
206 | # config.create_another = true
207 |
208 | # == Register Stylesheets & Javascripts
209 | #
210 | # We recommend using the built in Active Admin layout and loading
211 | # up your own stylesheets / javascripts to customize the look
212 | # and feel.
213 | #
214 | # To load a stylesheet:
215 | # config.register_stylesheet 'my_stylesheet.css'
216 | #
217 | # You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
218 | # config.register_stylesheet 'my_print_stylesheet.css', media: :print
219 | #
220 | # To load a javascript file:
221 | # config.register_javascript 'my_javascript.js'
222 |
223 | # == CSV options
224 | #
225 | # Set the CSV builder separator
226 | # config.csv_options = { col_sep: ';' }
227 | #
228 | # Force the use of quotes
229 | # config.csv_options = { force_quotes: true }
230 |
231 | # == Menu System
232 | #
233 | # You can add a navigation menu to be used in your application, or configure a provided menu
234 | #
235 | # To change the default utility navigation to show a link to your website & a logout btn
236 | #
237 | # config.namespace :admin do |admin|
238 | # admin.build_menu :utility_navigation do |menu|
239 | # menu.add label: 'My Great Website', url: 'http://www.mygreatwebsite.com', html_options: { target: :blank }
240 | # admin.add_logout_button_to_menu menu
241 | # end
242 | # end
243 | #
244 | # If you wanted to add a static menu item to the default menu provided:
245 | #
246 | # config.namespace :admin do |admin|
247 | # admin.build_menu :default do |menu|
248 | # menu.add label: 'My Great Website', url: 'http://www.mygreatwebsite.com', html_options: { target: :blank }
249 | # end
250 | # end
251 |
252 | # == Download Links
253 | #
254 | # You can disable download links on resource listing pages,
255 | # or customize the formats shown per namespace/globally
256 | #
257 | # To disable/customize for the :admin namespace:
258 | #
259 | # config.namespace :admin do |admin|
260 | #
261 | # # Disable the links entirely
262 | # admin.download_links = false
263 | #
264 | # # Only show XML & PDF options
265 | # admin.download_links = [:xml, :pdf]
266 | #
267 | # # Enable/disable the links based on block
268 | # # (for example, with cancan)
269 | # admin.download_links = proc { can?(:view_download_links) }
270 | #
271 | # end
272 |
273 | # == Pagination
274 | #
275 | # Pagination is enabled by default for all resources.
276 | # You can control the default per page count for all resources here.
277 | #
278 | # config.default_per_page = 30
279 | #
280 | # You can control the max per page count too.
281 | #
282 | # config.max_per_page = 10_000
283 |
284 | # == Filters
285 | #
286 | # By default the index screen includes a 'Filters' sidebar on the right
287 | # hand side with a filter for each attribute of the registered model.
288 | # You can enable or disable them for all resources here.
289 | #
290 | # config.filters = true
291 | #
292 | # By default the filters include associations in a select, which means
293 | # that every record will be loaded for each association (up
294 | # to the value of config.maximum_association_filter_arity).
295 | # You can enabled or disable the inclusion
296 | # of those filters by default here.
297 | #
298 | # config.include_default_association_filters = true
299 |
300 | # config.maximum_association_filter_arity = 256 # default value of :unlimited will change to 256 in a future version
301 | # config.filter_columns_for_large_association, [
302 | # :display_name,
303 | # :full_name,
304 | # :name,
305 | # :username,
306 | # :login,
307 | # :title,
308 | # :email,
309 | # ]
310 | # config.filter_method_for_large_association, '_starts_with'
311 |
312 | # == Head
313 | #
314 | # You can add your own content to the site head like analytics. Make sure
315 | # you only pass content you trust.
316 | #
317 | # config.head = ''.html_safe
318 |
319 | # == Footer
320 | #
321 | # By default, the footer shows the current Active Admin version. You can
322 | # override the content of the footer here.
323 | #
324 | # config.footer = 'my custom footer text'
325 |
326 | # == Sorting
327 | #
328 | # By default ActiveAdmin::OrderClause is used for sorting logic
329 | # You can inherit it with own class and inject it for all resources
330 | #
331 | # config.order_clause = MyOrderClause
332 | end
333 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Rails Template
2 |
3 | [](https://codeclimate.com/github/TristanToye/rails-template/maintainability) [](https://codeclimate.com/github/TristanToye/rails-template/test_coverage) [](https://circleci.com/gh/TristanToye/rails-template)  [](https://github.com/TristanToye/rails-template/blob/master/LICENSE)   
4 | [](https://heroku.com/deploy?template=https://github.com/TristanToye/rails-template) [](https://azuredeploy.net/?repository=https://github.com/TristanToye/rails-template)
5 |
6 | A MVP ready template for Rails apps.
7 |
8 | Everything used in this repo is open source, free, or optional.
9 |
10 | This repo focuses on getting your project setup ASAP with all the tooling to start deploying from your first commit.
11 |
12 | ## ⬆️ Versions
13 | - [Live Demo (master branch)](http://demo.railstemplate.com)
14 | - [Rails 6.x](https://github.com/TristanToye/rails-template/)
15 | - [Rails 5.x](https://github.com/TristanToye/rails-template/tree/v1.1)
16 | - [Rails 4.x](https://github.com/TristanToye/rails-4-boilerplate)
17 |
18 | ## ✨ Features
19 | - User Accounts & Authentication: [Devise](https://github.com/plataformatec/devise)
20 | - Feature Switching with a UI: [flipper](https://github.com/jnunemaker/flipper)
21 | - Admin Dashboard UI: [ActiveAdmin](https://github.com/activeadmin/activeadmin)
22 | - Secrets Management: [dotenv](https://github.com/bkeepers/dotenv)
23 | - Livereload for Development: [Guard](https://github.com/guard/guard)
24 | - Upgraded Testing Suite: [RSpec](https://github.com/rspec/rspec), [faker](https://github.com/stympy/faker), [factory_bot](https://github.com/thoughtbot/factory_bot)
25 | - Static Analysis: [Brakeman](https://github.com/presidentbeef/brakeman), [Rubopcop](https://github.com/rubocop-hq/rubocop)
26 | - Continuous Integration: [CircleCI](https://circleci.com), [CodeClimate](https://codeclimate.com)
27 | - Code Coverage Reporting with a UI: [simplecov](https://github.com/colszowka/simplecov)
28 |
29 | ## 📝 Guides
30 | - [Getting started](https://github.com/TristanToye/rails-template#-getting-started)
31 | - [Local setup](https://github.com/TristanToye/rails-template#-local-setup)
32 | - [Feature Switches](https://github.com/TristanToye/rails-template#-feature-switches)
33 | - [Admin Dashboard](https://github.com/TristanToye/rails-template#-admin-dashboard)
34 | - [Testing](https://github.com/TristanToye/rails-template#-testing)
35 | - [Code Coverage](https://github.com/TristanToye/rails-template#-code-coverage)
36 | - [Static Analysis](https://github.com/TristanToye/rails-template#-static-analysis)
37 | - [Deployment](https://github.com/TristanToye/rails-template#-static-analysis)
38 | - [Continuous Integration](https://github.com/TristanToye/rails-template#-continuous-integration)
39 | - [Mailer Setup](https://github.com/TristanToye/rails-template#-mailer-setup)
40 | - Custom Domain, DNS, & SSL - coming soon
41 |
42 | ## 📦 Getting Started
43 | To setup the repo locally start by cloning it locally:
44 | ```
45 | git clone https://github.com/TristanToye/rails-template.git
46 | cd rails-template
47 | ```
48 |
49 | ## 🔧 Local Setup
50 | Next you need to install all the dependiencies:
51 | - ruby 2.7.4
52 | - rails 6
53 | - node 8.16.0
54 | - postgres 10
55 |
56 | To accomplish this I recommend the following:
57 | - install homebrew
58 | - install RVM
59 | - install ruby 2.7.4 with RVM
60 | - install rails 6
61 | - install NVM
62 | - install node 8.16.0 with NVM
63 | - install postgres 10
64 |
65 | This guide walks you through it in details: http://railsapps.github.io/installrubyonrails-mac.html
66 |
67 | The only issue you might run into is setting up Postgres. If you use the recommend Postgres app (do this). When installing the `pg` gem you will need to run the following:
68 | ```
69 | gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/10/bin/pg_config
70 | ```
71 |
72 | Or you can add the app's config to your `~./bash_profile`:
73 | ```
74 | export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
75 | ```
76 |
77 | Once you have everything installed, run bundler to get our gems setup:
78 | ```
79 | $ bundle install
80 | ```
81 |
82 | ### 🔒 Setup Secrets
83 | For most credentials we want to use the Rails 5.2 credential management. This article explains it well with examples: https://medium.com/cedarcode/rails-5-2-credentials-9b3324851336
84 |
85 | To get started here go delete my credentials located at `/config/credentials.yml.enc`.
86 |
87 | We will start by adding a `secret_key_base` to this file:
88 | ```
89 | $ rake secret
90 | 840f20e6084666b7aabe9d94...
91 | $ EDITOR="code --wait" rails credentials:edit
92 |
93 | # In the credentials file add the following
94 | secret_key_base=840f20e6084666b7aabe9d94...
95 | ```
96 |
97 | We also likely want to handle some environment variables locally. We use a git-ignored file to load them when the app starts.
98 |
99 | Create a new file `.env` in the root of the repo. This will load any environment variables you might need to set in the future.
100 |
101 | ### 🗃 Generate Local Database
102 | Makes sure postgres is running and setup your database:
103 | ```
104 | $ rails db:setup db:schema:load
105 | ```
106 |
107 | Now you should be able to start your rails app and load it in your browser at http://localhost:3000:
108 | ```
109 | # to start with spring and all the goodies
110 | $ guard
111 |
112 | # OR to start just the rails server
113 | $ rails s
114 | ```
115 |
116 | ## 🐬 Feature Switches
117 | This app uses the lovely [Flipper gem](https://github.com/jnunemaker/flipper) to manage features.
118 |
119 | It is protected with a basic auth. Add the following to your credentials:
120 | ```
121 | $ EDITOR="code --wait" rails credentials:edit
122 |
123 | # In the file
124 | flipper:
125 | user_name: YOUR_USERNAME
126 | password: YOUR_PASSWORD
127 | ```
128 |
129 | Then navigate to http://localhost:3000/flipper/features & enter your credentials.
130 |
131 | Add the feature `show_auth` and enable it for everyone. This should show the login/signup links on the index of the app.
132 |
133 | ## 🔑 Admin Dashboard
134 | This app uses the [ActiveAdmin](https://github.com/activeadmin/activeadmin) gem to generate an admin UI.
135 |
136 | This is already up and running as part of your app! You just need to create an admin user to access it.
137 |
138 | Signup on your app and try navigate to http://localhost:3000/admin - you should be unable to access it yet.
139 |
140 | You need to set the boolean column `admin` on your user account to `true`.
141 |
142 | This is pretty fast to do from the rails console:
143 | ```
144 | $ rails c
145 | > User.find_by(email: 'YOUR_ACCOUNTS_EMAIL').update(admin: true)
146 | ```
147 |
148 | Now navigate to http://localhost:3000/admin and you should see the blank admin UI.
149 |
150 | You will need to [read the docs](https://activeadmin.info/documentation.html) to find out how to extend this for your own purposes.
151 |
152 | ## ✅ Testing
153 | You can start your app, and run your livereloading test suite with one command: `$ guard`
154 |
155 | Once guard is running, simply push `return` to run all tests & static checks.
156 | For more info check the Guard related gems in the `Gemfile`.
157 |
158 | To run the test suite on its own: `$ rspec`
159 |
160 | For more info check the RSpec related gems in the `Gemfile`.
161 |
162 | ## 🔧 Code Coverage
163 | Code coverage is setup with simplecov.
164 |
165 | Run your test suite: `$ rspec`
166 |
167 | In your apps directory open `./coverage/index.html` in a browser to view a UI for the code coverage of your app.
168 |
169 | If you start the app with the `$ guard` command the code coverage will update coverage on each saved change.
170 |
171 | ## 🚨 Static Analysis
172 | There are multiple gems integrated in this app for static analysis.
173 |
174 | These all run as part of the `$ guard` command during development.
175 |
176 | Rubocop: ruby style guide, [read more here](https://github.com/rubocop-hq/rubocop). To use run: `$ rubocop`.
177 |
178 | Brakeman: security analysis, [read more here](https://github.com/presidentbeef/brakeman). To use run: `$ brakeman`.
179 |
180 | ## 🚀 Deployment
181 |
182 | [](https://heroku.com/deploy?template=https://github.com/TristanToye/rails-template)
183 |
184 | We are going to deloy this [Heroku](https://www.heroku.com/)
185 |
186 | Create an account and create your first app. Add to your app the free tier of [Heroku Postgres](https://www.heroku.com/postgres) & [Papertrail](https://elements.heroku.com/addons/papertrail).
187 |
188 | Next install the CLI locally & login: https://devcenter.heroku.com/articles/heroku-cli
189 |
190 | Add your `.env` variables to the [settings tab on your Heroku app](https://devcenter.heroku.com/articles/config-vars#using-the-heroku-dashboard).
191 |
192 | You will also need to add the contents of your `config/master.key` file to Heroku as `RAILS_MASTER_KEY` in the same setting location to allow Heroku to use your credentials.
193 |
194 | Deploy your repo from the `deploy` tab by connecting your github account and selecting the repo OR follow the linked guide below to deloy directly from your machine.
195 |
196 | Finally, run the following to setup you database on the Heroku Postgres instance:
197 | ```
198 | heroku run rails db:schema:load -a APP_NAME
199 | ```
200 |
201 | Heroku has a great set of documentation on how to get setup: https://devcenter.heroku.com/articles/getting-started-with-rails5
202 |
203 | ## 👷 Continuous Integration
204 | This section could be expanded, but out of ther box there are some basic tools in place.
205 |
206 | ### CircleCi
207 | Use this for CI with Heroku to ensure all your tests pass before deploying a new version, before merging your latest PRs etc.
208 |
209 | You get one free linux box to run tests on: https://circleci.com
210 |
211 | Connect your github account and select the repo to start running tests.
212 |
213 | By default this is configured to push code coverage to CodeClimate (see below).
214 |
215 | If you don't want to use CodeClimate comment out lines 94-96 from [.circleci/config.yml](https://github.com/TristanToye/rails-template/blob/master/.circleci/config.yml#L94):
216 | ```
217 | - send-code-coverage:
218 | requires:
219 | - build-rails
220 | ```
221 |
222 | Once setup and you have your tests passing you can enable the option on Heroku to `Wait for CI to pass before deploy` from the `Deploy` tab of you app.
223 |
224 | ### CodeClimate
225 | Use this for tracking issues, code coverage etc.
226 |
227 | Free for open source: https://codeclimate.com/
228 |
229 | Sign in with github & connect your repo.
230 |
231 | Add this environment variable to CirclCi: `CC_TEST_REPORTER_ID`
232 |
233 | I highly recommend installing the browser extension: https://chrome.google.com/webstore/detail/code-climate/phgahogocbnfilkegjdpohgkkjgahjgk
234 |
235 | ## ✉️ Mailer Setup
236 |
237 | ### GMail SMTP Free Sending
238 | If you have a gmail account this is a simple solution. You might want to create a new Gmail just for this app.
239 |
240 | Add to your credentials the following:
241 | ```
242 | $ EDITOR="code --wait" rails credentials:edit
243 |
244 | # In the file opened add
245 | email:
246 | host: smtp.gmail.com
247 | user_name: YOUR_GMAIL_EMAIL
248 | password: YOUR_GMAIL_PASSWORD
249 | ```
250 |
251 | ### Mail Service
252 | You will require a real domain that you own to send email from.
253 |
254 | Sign up with a provider like https://sparkpost.com for a free plan.
255 |
256 | Verify your domain with them.
257 |
258 | Select SMTP sending and get their config.
259 |
260 | Add to your credentials the following:
261 | ```
262 | $ EDITOR="code --wait" rails credentials:edit
263 |
264 | # In the file opened add
265 | email:
266 | host: HOST_DOMAIN
267 | user_name: PROVIDED_USER_NAME
268 | password: PROVIDED_PASSWORD
269 | ```
270 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actioncable (6.0.3.7)
5 | actionpack (= 6.0.3.7)
6 | nio4r (~> 2.0)
7 | websocket-driver (>= 0.6.1)
8 | actionmailbox (6.0.3.7)
9 | actionpack (= 6.0.3.7)
10 | activejob (= 6.0.3.7)
11 | activerecord (= 6.0.3.7)
12 | activestorage (= 6.0.3.7)
13 | activesupport (= 6.0.3.7)
14 | mail (>= 2.7.1)
15 | actionmailer (6.0.3.7)
16 | actionpack (= 6.0.3.7)
17 | actionview (= 6.0.3.7)
18 | activejob (= 6.0.3.7)
19 | mail (~> 2.5, >= 2.5.4)
20 | rails-dom-testing (~> 2.0)
21 | actionpack (6.0.3.7)
22 | actionview (= 6.0.3.7)
23 | activesupport (= 6.0.3.7)
24 | rack (~> 2.0, >= 2.0.8)
25 | rack-test (>= 0.6.3)
26 | rails-dom-testing (~> 2.0)
27 | rails-html-sanitizer (~> 1.0, >= 1.2.0)
28 | actiontext (6.0.3.7)
29 | actionpack (= 6.0.3.7)
30 | activerecord (= 6.0.3.7)
31 | activestorage (= 6.0.3.7)
32 | activesupport (= 6.0.3.7)
33 | nokogiri (>= 1.8.5)
34 | actionview (6.0.3.7)
35 | activesupport (= 6.0.3.7)
36 | builder (~> 3.1)
37 | erubi (~> 1.4)
38 | rails-dom-testing (~> 2.0)
39 | rails-html-sanitizer (~> 1.1, >= 1.2.0)
40 | activeadmin (2.9.0)
41 | arbre (~> 1.2, >= 1.2.1)
42 | formtastic (>= 3.1, < 5.0)
43 | formtastic_i18n (~> 0.4)
44 | inherited_resources (~> 1.7)
45 | jquery-rails (~> 4.2)
46 | kaminari (~> 1.0, >= 1.2.1)
47 | railties (>= 5.2, < 6.2)
48 | ransack (~> 2.1, >= 2.1.1)
49 | activejob (6.0.3.7)
50 | activesupport (= 6.0.3.7)
51 | globalid (>= 0.3.6)
52 | activemodel (6.0.3.7)
53 | activesupport (= 6.0.3.7)
54 | activerecord (6.0.3.7)
55 | activemodel (= 6.0.3.7)
56 | activesupport (= 6.0.3.7)
57 | activestorage (6.0.3.7)
58 | actionpack (= 6.0.3.7)
59 | activejob (= 6.0.3.7)
60 | activerecord (= 6.0.3.7)
61 | marcel (~> 1.0.0)
62 | activesupport (6.0.3.7)
63 | concurrent-ruby (~> 1.0, >= 1.0.2)
64 | i18n (>= 0.7, < 2)
65 | minitest (~> 5.1)
66 | tzinfo (~> 1.1)
67 | zeitwerk (~> 2.2, >= 2.2.2)
68 | addressable (2.8.0)
69 | public_suffix (>= 2.0.2, < 5.0)
70 | arbre (1.4.0)
71 | activesupport (>= 3.0.0, < 6.2)
72 | ruby2_keywords (>= 0.0.2, < 1.0)
73 | ast (2.4.2)
74 | autoprefixer-rails (10.3.3.0)
75 | execjs (~> 2)
76 | bcrypt (3.1.16)
77 | bindex (0.8.1)
78 | bootsnap (1.9.1)
79 | msgpack (~> 1.0)
80 | bootstrap (4.3.1)
81 | autoprefixer-rails (>= 9.1.0)
82 | popper_js (>= 1.14.3, < 2)
83 | sassc-rails (>= 2.0.0)
84 | brakeman (5.1.1)
85 | builder (3.2.4)
86 | byebug (11.1.3)
87 | capybara (3.35.3)
88 | addressable
89 | mini_mime (>= 0.1.3)
90 | nokogiri (~> 1.8)
91 | rack (>= 1.6.0)
92 | rack-test (>= 0.6.3)
93 | regexp_parser (>= 1.5, < 3.0)
94 | xpath (~> 3.2)
95 | childprocess (4.1.0)
96 | coderay (1.1.3)
97 | concurrent-ruby (1.1.9)
98 | crass (1.0.6)
99 | database_cleaner (2.0.1)
100 | database_cleaner-active_record (~> 2.0.0)
101 | database_cleaner-active_record (2.0.1)
102 | activerecord (>= 5.a)
103 | database_cleaner-core (~> 2.0.0)
104 | database_cleaner-core (2.0.1)
105 | devise (4.8.0)
106 | bcrypt (~> 3.0)
107 | orm_adapter (~> 0.1)
108 | railties (>= 4.1.0)
109 | responders
110 | warden (~> 1.2.3)
111 | devise-bootstrap-views (1.1.0)
112 | devise-i18n (1.10.0)
113 | devise (>= 4.8.0)
114 | diff-lcs (1.4.4)
115 | docile (1.4.0)
116 | dotenv (2.7.6)
117 | dotenv-rails (2.7.6)
118 | dotenv (= 2.7.6)
119 | railties (>= 3.2)
120 | em-websocket (0.5.2)
121 | eventmachine (>= 0.12.9)
122 | http_parser.rb (~> 0.6.0)
123 | erubi (1.10.0)
124 | eventmachine (1.2.7)
125 | execjs (2.8.1)
126 | factory_bot (4.11.1)
127 | activesupport (>= 3.0.0)
128 | factory_bot_rails (4.11.1)
129 | factory_bot (~> 4.11.1)
130 | railties (>= 3.0.0)
131 | faker (1.9.6)
132 | i18n (>= 0.7)
133 | ffi (1.15.4)
134 | flipper (0.22.2)
135 | flipper-active_record (0.22.2)
136 | activerecord (>= 4.2, < 7)
137 | flipper (~> 0.22.2)
138 | flipper-ui (0.22.2)
139 | erubi (>= 1.0.0, < 2.0.0)
140 | flipper (~> 0.22.2)
141 | rack (>= 1.4, < 3)
142 | rack-protection (>= 1.5.3, < 2.2.0)
143 | formatador (0.3.0)
144 | formtastic (4.0.0)
145 | actionpack (>= 5.2.0)
146 | formtastic_i18n (0.7.0)
147 | globalid (0.5.2)
148 | activesupport (>= 5.0)
149 | guard (2.18.0)
150 | formatador (>= 0.2.4)
151 | listen (>= 2.7, < 4.0)
152 | lumberjack (>= 1.0.12, < 2.0)
153 | nenv (~> 0.1)
154 | notiffany (~> 0.0)
155 | pry (>= 0.13.0)
156 | shellany (~> 0.0)
157 | thor (>= 0.18.1)
158 | guard-brakeman (0.8.6)
159 | brakeman (>= 2.1.1)
160 | guard (>= 2.0.0)
161 | guard-compat (~> 1.0)
162 | guard-compat (1.2.1)
163 | guard-livereload (2.5.2)
164 | em-websocket (~> 0.5)
165 | guard (~> 2.8)
166 | guard-compat (~> 1.0)
167 | multi_json (~> 1.8)
168 | guard-rails (0.8.1)
169 | guard (~> 2.11)
170 | guard-compat (~> 1.0)
171 | guard-rspec (4.7.3)
172 | guard (~> 2.1)
173 | guard-compat (~> 1.1)
174 | rspec (>= 2.99.0, < 4.0)
175 | guard-spring (1.1.1)
176 | guard (~> 2.0)
177 | guard-compat (~> 1.1)
178 | spring
179 | has_scope (0.8.0)
180 | actionpack (>= 5.2)
181 | activesupport (>= 5.2)
182 | http_parser.rb (0.6.0)
183 | i18n (1.8.10)
184 | concurrent-ruby (~> 1.0)
185 | inherited_resources (1.13.0)
186 | actionpack (>= 5.2, < 6.2)
187 | has_scope (~> 0.6)
188 | railties (>= 5.2, < 6.2)
189 | responders (>= 2, < 4)
190 | jbuilder (2.11.2)
191 | activesupport (>= 5.0.0)
192 | jquery-rails (4.4.0)
193 | rails-dom-testing (>= 1, < 3)
194 | railties (>= 4.2.0)
195 | thor (>= 0.14, < 2.0)
196 | json (2.6.1)
197 | kaminari (1.2.1)
198 | activesupport (>= 4.1.0)
199 | kaminari-actionview (= 1.2.1)
200 | kaminari-activerecord (= 1.2.1)
201 | kaminari-core (= 1.2.1)
202 | kaminari-actionview (1.2.1)
203 | actionview
204 | kaminari-core (= 1.2.1)
205 | kaminari-activerecord (1.2.1)
206 | activerecord
207 | kaminari-core (= 1.2.1)
208 | kaminari-core (1.2.1)
209 | listen (3.1.5)
210 | rb-fsevent (~> 0.9, >= 0.9.4)
211 | rb-inotify (~> 0.9, >= 0.9.7)
212 | ruby_dep (~> 1.2)
213 | loofah (2.12.0)
214 | crass (~> 1.0.2)
215 | nokogiri (>= 1.5.9)
216 | lumberjack (1.2.8)
217 | mail (2.7.1)
218 | mini_mime (>= 0.1.1)
219 | marcel (1.0.2)
220 | method_source (1.0.0)
221 | mini_mime (1.1.2)
222 | mini_portile2 (2.6.1)
223 | minitest (5.14.4)
224 | msgpack (1.4.2)
225 | multi_json (1.15.0)
226 | nenv (0.3.0)
227 | nio4r (2.5.8)
228 | nokogiri (1.12.5)
229 | mini_portile2 (~> 2.6.1)
230 | racc (~> 1.4)
231 | nokogiri (1.12.5-x86_64-linux)
232 | racc (~> 1.4)
233 | notiffany (0.1.3)
234 | nenv (~> 0.1)
235 | shellany (~> 0.0)
236 | orm_adapter (0.5.0)
237 | parallel (1.21.0)
238 | parser (3.0.2.0)
239 | ast (~> 2.4.1)
240 | pg (1.2.3)
241 | popper_js (1.16.0)
242 | pry (0.14.1)
243 | coderay (~> 1.1)
244 | method_source (~> 1.0)
245 | pry-rails (0.3.9)
246 | pry (>= 0.10.4)
247 | public_suffix (4.0.6)
248 | puma (4.3.10)
249 | nio4r (~> 2.0)
250 | racc (1.6.0)
251 | rack (2.2.3)
252 | rack-livereload (0.3.17)
253 | rack
254 | rack-protection (2.1.0)
255 | rack
256 | rack-proxy (0.7.0)
257 | rack
258 | rack-test (1.1.0)
259 | rack (>= 1.0, < 3)
260 | rails (6.0.3.7)
261 | actioncable (= 6.0.3.7)
262 | actionmailbox (= 6.0.3.7)
263 | actionmailer (= 6.0.3.7)
264 | actionpack (= 6.0.3.7)
265 | actiontext (= 6.0.3.7)
266 | actionview (= 6.0.3.7)
267 | activejob (= 6.0.3.7)
268 | activemodel (= 6.0.3.7)
269 | activerecord (= 6.0.3.7)
270 | activestorage (= 6.0.3.7)
271 | activesupport (= 6.0.3.7)
272 | bundler (>= 1.3.0)
273 | railties (= 6.0.3.7)
274 | sprockets-rails (>= 2.0.0)
275 | rails-controller-testing (1.0.5)
276 | actionpack (>= 5.0.1.rc1)
277 | actionview (>= 5.0.1.rc1)
278 | activesupport (>= 5.0.1.rc1)
279 | rails-dom-testing (2.0.3)
280 | activesupport (>= 4.2.0)
281 | nokogiri (>= 1.6)
282 | rails-html-sanitizer (1.4.2)
283 | loofah (~> 2.3)
284 | railties (6.0.3.7)
285 | actionpack (= 6.0.3.7)
286 | activesupport (= 6.0.3.7)
287 | method_source
288 | rake (>= 0.8.7)
289 | thor (>= 0.20.3, < 2.0)
290 | rainbow (3.0.0)
291 | rake (13.0.6)
292 | ransack (2.4.2)
293 | activerecord (>= 5.2.4)
294 | activesupport (>= 5.2.4)
295 | i18n
296 | rb-fsevent (0.11.0)
297 | rb-inotify (0.10.1)
298 | ffi (~> 1.0)
299 | regexp_parser (2.1.1)
300 | responders (3.0.1)
301 | actionpack (>= 5.0)
302 | railties (>= 5.0)
303 | rexml (3.2.5)
304 | rspec (3.10.0)
305 | rspec-core (~> 3.10.0)
306 | rspec-expectations (~> 3.10.0)
307 | rspec-mocks (~> 3.10.0)
308 | rspec-core (3.10.1)
309 | rspec-support (~> 3.10.0)
310 | rspec-expectations (3.10.1)
311 | diff-lcs (>= 1.2.0, < 2.0)
312 | rspec-support (~> 3.10.0)
313 | rspec-mocks (3.10.2)
314 | diff-lcs (>= 1.2.0, < 2.0)
315 | rspec-support (~> 3.10.0)
316 | rspec-rails (4.0.0.beta3)
317 | actionpack (>= 4.2)
318 | activesupport (>= 4.2)
319 | railties (>= 4.2)
320 | rspec-core (~> 3.8)
321 | rspec-expectations (~> 3.8)
322 | rspec-mocks (~> 3.8)
323 | rspec-support (~> 3.8)
324 | rspec-support (3.10.2)
325 | rubocop (0.93.1)
326 | parallel (~> 1.10)
327 | parser (>= 2.7.1.5)
328 | rainbow (>= 2.2.2, < 4.0)
329 | regexp_parser (>= 1.8)
330 | rexml
331 | rubocop-ast (>= 0.6.0)
332 | ruby-progressbar (~> 1.7)
333 | unicode-display_width (>= 1.4.0, < 2.0)
334 | rubocop-ast (1.12.0)
335 | parser (>= 3.0.1.1)
336 | rubocop-rspec (1.44.1)
337 | rubocop (~> 0.87)
338 | rubocop-ast (>= 0.7.1)
339 | ruby-progressbar (1.11.0)
340 | ruby2_keywords (0.0.5)
341 | ruby_dep (1.5.0)
342 | rubyzip (2.3.2)
343 | sass-rails (6.0.0)
344 | sassc-rails (~> 2.1, >= 2.1.1)
345 | sassc (2.4.0)
346 | ffi (~> 1.9)
347 | sassc-rails (2.1.2)
348 | railties (>= 4.0.0)
349 | sassc (>= 2.0)
350 | sprockets (> 3.0)
351 | sprockets-rails
352 | tilt
353 | selenium-webdriver (4.0.3)
354 | childprocess (>= 0.5, < 5.0)
355 | rexml (~> 3.2, >= 3.2.5)
356 | rubyzip (>= 1.2.2)
357 | shellany (0.0.1)
358 | shoulda-matchers (4.0.0.rc1)
359 | activesupport (>= 4.2.0)
360 | simplecov (0.17.1)
361 | docile (~> 1.1)
362 | json (>= 1.8, < 3)
363 | simplecov-html (~> 0.10.0)
364 | simplecov-html (0.10.2)
365 | spring (2.1.1)
366 | spring-commands-rspec (1.0.4)
367 | spring (>= 0.9.1)
368 | spring-commands-rubocop (0.2.0)
369 | spring (>= 1.0, < 3.0)
370 | spring-watcher-listen (2.0.1)
371 | listen (>= 2.7, < 4.0)
372 | spring (>= 1.2, < 3.0)
373 | sprockets (4.0.2)
374 | concurrent-ruby (~> 1.0)
375 | rack (> 1, < 3)
376 | sprockets-rails (3.2.2)
377 | actionpack (>= 4.0)
378 | activesupport (>= 4.0)
379 | sprockets (>= 3.0.0)
380 | thor (1.1.0)
381 | thread_safe (0.3.6)
382 | tilt (2.0.10)
383 | turbolinks (5.2.1)
384 | turbolinks-source (~> 5.2)
385 | turbolinks-source (5.2.0)
386 | tzinfo (1.2.9)
387 | thread_safe (~> 0.1)
388 | unicode-display_width (1.8.0)
389 | warden (1.2.9)
390 | rack (>= 2.0.9)
391 | web-console (4.1.0)
392 | actionview (>= 6.0.0)
393 | activemodel (>= 6.0.0)
394 | bindex (>= 0.4.0)
395 | railties (>= 6.0.0)
396 | webdrivers (5.0.0)
397 | nokogiri (~> 1.6)
398 | rubyzip (>= 1.3.0)
399 | selenium-webdriver (~> 4.0)
400 | webpacker (4.3.0)
401 | activesupport (>= 4.2)
402 | rack-proxy (>= 0.6.1)
403 | railties (>= 4.2)
404 | websocket-driver (0.7.5)
405 | websocket-extensions (>= 0.1.0)
406 | websocket-extensions (0.1.5)
407 | xpath (3.2.0)
408 | nokogiri (~> 1.8)
409 | zeitwerk (2.5.1)
410 |
411 | PLATFORMS
412 | ruby
413 | x86_64-linux
414 |
415 | DEPENDENCIES
416 | activeadmin
417 | bootsnap (>= 1.4.2)
418 | bootstrap (~> 4.3.1)
419 | brakeman
420 | bundler (= 2.2.25)
421 | byebug
422 | capybara (>= 2.15)
423 | database_cleaner
424 | devise (>= 4.7.1)
425 | devise-bootstrap-views (~> 1.0)
426 | devise-i18n
427 | dotenv-rails
428 | factory_bot_rails (~> 4.11)
429 | faker (~> 1.9)
430 | flipper
431 | flipper-active_record
432 | flipper-ui
433 | guard
434 | guard-brakeman
435 | guard-livereload (~> 2.5)
436 | guard-rails
437 | guard-rspec
438 | guard-spring
439 | jbuilder (~> 2.7)
440 | jquery-rails
441 | listen (>= 3.0.5, < 3.2)
442 | pg (>= 0.18, < 2.0)
443 | pry-rails
444 | puma (~> 4.3)
445 | rack-livereload
446 | rails (~> 6.0.3.6)
447 | rails-controller-testing
448 | rspec-rails (= 4.0.0.beta3)
449 | rubocop (~> 0.78)
450 | rubocop-rspec (~> 1.25)
451 | sass-rails (>= 6)
452 | selenium-webdriver
453 | shoulda-matchers (= 4.0.0.rc1)
454 | simplecov (< 0.18)
455 | spring
456 | spring-commands-rspec
457 | spring-commands-rubocop
458 | spring-watcher-listen (~> 2.0.0)
459 | turbolinks (~> 5)
460 | tzinfo-data
461 | web-console (>= 3.3.0)
462 | webdrivers
463 | webpacker (~> 4.0)
464 |
465 | RUBY VERSION
466 | ruby 2.7.4p191
467 |
468 | BUNDLED WITH
469 | 2.2.25
470 |
--------------------------------------------------------------------------------
/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 = '6caee2aa904e3e83b4fe9e80f5cbe44b71bf5a48bc70b84e2a7263b2bd66c9864031aefe1e55943ee2abbd429c68d6100a656da907bc9aec0b4eb8bf20af9d8d'
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 = 'dba2e201ebd6c6d9e4ab985e641a61543b5bf802e0fb5870d8c92ec2bd7418c4afd2e3aee789f0c0d5c475a8678ee5df35f09b7867a0592fdfdb548108e80bc9'
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 = 8..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 |
--------------------------------------------------------------------------------