├── .dockerignore ├── .editorconfig ├── .eslintrc.js ├── .github ├── dependabot.yml └── workflows │ ├── docker.yml │ ├── eslint.yml │ ├── rspec.yml │ └── webpacker.yml ├── .gitignore ├── .prettierrc ├── .rspec ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── Procfile ├── Procfile.dev ├── README.md ├── Rakefile ├── app ├── assets │ ├── config │ │ └── manifest.js │ └── images │ │ └── .keep ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── controllers │ ├── api │ │ ├── base_controller.rb │ │ ├── home_controller.rb │ │ └── posts_controller.rb │ ├── application_controller.rb │ └── concerns │ │ └── .keep ├── helpers │ └── application_helper.rb ├── javascript │ ├── axios_client.ts │ ├── components │ │ ├── layout.vue │ │ └── post.vue │ ├── packs │ │ └── application.ts │ ├── pages │ │ ├── errors │ │ │ └── 404.vue │ │ ├── home │ │ │ └── index.vue │ │ └── privacy │ │ │ └── index.vue │ ├── routes.ts │ ├── shims │ │ └── vue.shim.d.ts │ └── stylesheets │ │ └── application.css ├── jobs │ └── application_job.rb ├── mailers │ └── application_mailer.rb ├── models │ ├── application_record.rb │ └── concerns │ │ └── .keep └── views │ ├── application │ └── index.html.erb │ └── layouts │ ├── application.html.erb │ ├── mailer.html.erb │ └── mailer.text.erb ├── bin ├── bundle ├── rails ├── rake ├── setup ├── spring ├── webpack ├── webpack-dev-server └── yarn ├── config.ru ├── config ├── application.rb ├── boot.rb ├── cable.yml ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── application_controller_renderer.rb │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── content_security_policy.rb │ ├── cookies_serializer.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── new_framework_defaults_6_1.rb │ ├── permissions_policy.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── puma.rb ├── routes.rb ├── spring.rb ├── storage.yml ├── webpack │ ├── base.js │ ├── development.js │ ├── production.js │ ├── rules │ │ └── vue.js │ └── test.js └── webpacker.yml ├── db ├── schema.rb └── seeds.rb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── log └── .keep ├── package.json ├── postcss.config.js ├── public ├── 404.html ├── 422.html ├── 500.html ├── apple-touch-icon-precomposed.png ├── apple-touch-icon.png ├── favicon.ico └── robots.txt ├── spec ├── controllers │ ├── api │ │ ├── base_controller_spec.rb │ │ ├── home_controller_spec.rb │ │ └── posts_controller_spec.rb │ └── application_controller_spec.rb ├── rails_helper.rb ├── request │ └── api │ │ └── posts_spec.rb ├── spec_helper.rb └── support │ └── api_helpers.rb ├── storage └── .keep ├── tailwind.config.js ├── tmp └── .keep ├── tsconfig.json ├── vendor └── .keep └── yarn.lock /.dockerignore: -------------------------------------------------------------------------------- 1 | log/ 2 | tmp/ 3 | node_modules/ 4 | public/packs/ 5 | public/assets/ 6 | yarn-error.log 7 | .github 8 | pids 9 | test/ 10 | spec/ 11 | .github 12 | Dockerfile 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | max_line_length = 150 5 | 6 | [*.{css,js,json,scss,vue,erb,rb,ts}] 7 | charset = utf-8 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | indent_style = space 12 | indent_size = 2 13 | 14 | [*.yml] 15 | indent_size = 2 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: "vue-eslint-parser", 4 | parserOptions: { 5 | parser: "babel-eslint", 6 | sourceType: "module", 7 | ecmaVersion: 2020, 8 | }, 9 | extends: [ 10 | "airbnb-base", 11 | "plugin:import/errors", 12 | "plugin:import/warnings", 13 | "eslint:recommended", 14 | "plugin:vue/recommended", 15 | "prettier/vue", 16 | "plugin:prettier/recommended", 17 | "prettier", 18 | ], 19 | plugins: ["vue", "prettier"], 20 | env: { 21 | node: true, 22 | browser: true, 23 | }, 24 | rules: { 25 | "import/extensions": "off", 26 | }, 27 | overrides: [ 28 | { 29 | files: ["*.ts", "**/*.ts", "**/*.vue"], 30 | parser: "vue-eslint-parser", 31 | parserOptions: { 32 | parser: "@typescript-eslint/parser", 33 | sourceType: "module", 34 | ecmaVersion: 2020, 35 | }, 36 | extends: [ 37 | "airbnb-base", 38 | "plugin:import/errors", 39 | "plugin:import/warnings", 40 | "plugin:import/typescript", 41 | "eslint:recommended", 42 | "plugin:@typescript-eslint/recommended", 43 | "plugin:vue/recommended", 44 | "prettier/@typescript-eslint", 45 | "prettier/vue", 46 | "plugin:prettier/recommended", 47 | "prettier", 48 | ], 49 | rules: { 50 | "import/extensions": "off", 51 | }, 52 | env: { 53 | browser: true, 54 | jest: true, 55 | }, 56 | }, 57 | ], 58 | }; 59 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | 8 | - package-ecosystem: "bundler" 9 | directory: "/" 10 | schedule: 11 | interval: "daily" 12 | 13 | - package-ecosystem: "npm" 14 | directory: "/" 15 | schedule: 16 | interval: "daily" 17 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: Docker 2 | 3 | on: 4 | push: 5 | branches: master 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v2 13 | 14 | - name: Set up QEMU 15 | uses: docker/setup-qemu-action@v1 16 | 17 | - name: Set up Docker Buildx 18 | uses: docker/setup-buildx-action@v1 19 | 20 | - name: Cache Docker layers 21 | uses: actions/cache@v2 22 | with: 23 | path: /tmp/.docker-buildx-cache 24 | key: ${{ runner.os }}-docker-buildx-${{ github.sha }} 25 | restore-keys: ${{ runner.os }}-docker-buildx- 26 | 27 | - name: Login to Github Packages 28 | uses: docker/login-action@v1 29 | if: ${{ env.GHCR_TOKEN != '' }} 30 | env: 31 | GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} 32 | with: 33 | registry: ghcr.io 34 | username: ${{ github.repository_owner }} 35 | password: ${{ secrets.GHCR_TOKEN }} 36 | 37 | - name: Build 38 | id: docker_build 39 | uses: docker/build-push-action@v2 40 | env: 41 | GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} 42 | with: 43 | push: ${{ env.GHCR_TOKEN != '' }} 44 | tags: | 45 | ghcr.io/${{ github.repository }}:sha-${{ github.sha }} 46 | ghcr.io/${{ github.repository }}:latest 47 | cache-from: type=local,src=/tmp/.docker-buildx-cache 48 | cache-to: type=local,dest=/tmp/.docker-buildx-cache 49 | -------------------------------------------------------------------------------- /.github/workflows/eslint.yml: -------------------------------------------------------------------------------- 1 | name: ESLint 2 | 3 | on: push 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v2.3.3 11 | 12 | - name: Set up Node.js 13 | uses: actions/setup-node@v2.1.4 14 | with: 15 | node-version: 12 16 | 17 | - uses: actions/cache@v2 18 | with: 19 | path: '**/node_modules' 20 | key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} 21 | 22 | - name: Install Yarn dependencies 23 | run: yarn install 24 | 25 | - name: Run linters 26 | run: yarn lint 27 | -------------------------------------------------------------------------------- /.github/workflows/rspec.yml: -------------------------------------------------------------------------------- 1 | name: Rspec Tests 2 | 3 | on: push 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | services: 10 | postgres: 11 | image: postgres:12-alpine 12 | ports: 13 | - 5432:5432 14 | env: 15 | POSTGRES_PASSWORD: postgres 16 | options: >- 17 | --health-cmd pg_isready 18 | --health-interval 10s 19 | --health-timeout 5s 20 | --health-retries 5 21 | 22 | steps: 23 | - uses: actions/checkout@v2.3.3 24 | 25 | - uses: ruby/setup-ruby@v1 26 | with: 27 | ruby-version: 2.7.2 28 | bundler-cache: true 29 | 30 | - name: Install PostgreSQL client 31 | run: sudo apt-get -yqq install libpq-dev 32 | 33 | - run: bundle exec rails db:setup 34 | env: 35 | RAILS_ENV: test 36 | DATABASE_URL: postgresql://postgres:postgres@localhost/postgres 37 | 38 | - run: bundle exec rspec 39 | env: 40 | RAILS_ENV: test 41 | DATABASE_URL: postgresql://postgres:postgres@localhost/postgres 42 | -------------------------------------------------------------------------------- /.github/workflows/webpacker.yml: -------------------------------------------------------------------------------- 1 | name: Webpacker 2 | 3 | on: push 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v2.3.3 11 | 12 | - uses: ruby/setup-ruby@v1 13 | with: 14 | ruby-version: 2.7.2 15 | bundler-cache: true 16 | 17 | - name: Get yarn cache directory path 18 | id: yarn-cache-dir-path 19 | run: echo "::set-output name=dir::$(yarn cache dir)" 20 | 21 | - uses: actions/cache@v2 22 | id: yarn-cache 23 | with: 24 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 25 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 26 | restore-keys: | 27 | ${{ runner.os }}-yarn- 28 | 29 | - run: yarn install 30 | 31 | - run: bundle exec rails webpacker:compile 32 | env: 33 | RAILS_ENV: production 34 | SECRET_KEY_BASE: random 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/* 12 | /tmp/* 13 | !/log/.keep 14 | !/tmp/.keep 15 | 16 | # Ignore uploaded files in development. 17 | /storage/* 18 | !/storage/.keep 19 | 20 | /public/assets 21 | .byebug_history 22 | 23 | # Ignore master key for decrypting credentials and more. 24 | /config/master.key 25 | 26 | /public/packs 27 | /public/packs-test 28 | /node_modules 29 | /yarn-error.log 30 | yarn-debug.log* 31 | .yarn-integrity 32 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "useTabs": false 4 | } 5 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require rails_helper 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.7.2-alpine as base 2 | WORKDIR /app 3 | RUN apk update 4 | RUN apk add yarn git build-base postgresql-dev tzdata 5 | RUN gem install bundler:2.1.4 6 | RUN echo 'IRB.conf[:USE_MULTILINE] = false' > ~/.irbrc 7 | 8 | FROM base as bundle 9 | ADD Gemfile* /app/ 10 | RUN bundle config set no-cache 'true' 11 | RUN bundle config set without 'development test' 12 | RUN bundle install --jobs 4 --retry 2 && rm -rf /usr/local/bundle/cache 13 | 14 | FROM bundle as webpack 15 | WORKDIR /app 16 | COPY package.json /app/ 17 | COPY yarn.lock /app/ 18 | RUN yarn install --frozen-lockfile 19 | ADD . /app 20 | ENV RAILS_ENV='production' 21 | ENV SECRET_KEY_BASE='blank' 22 | RUN bundle exec rake webpacker:compile 23 | 24 | FROM base as runtime 25 | COPY --from=bundle /usr/local/bundle/ /usr/local/bundle/ 26 | COPY --from=webpack /app/public/packs /app/public/packs 27 | ADD . /app 28 | RUN mkdir -p tmp/pids 29 | RUN bundle exec bootsnap precompile --gemfile app/ lib/ 30 | 31 | CMD ["bundle", "exec", "puma"] 32 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby '2.7.2' 5 | 6 | gem 'rails', '~> 6.1.1' 7 | gem 'pg', '>= 0.18', '< 2.0' 8 | gem 'puma', '~> 5' 9 | gem "webpacker", '6.0.0.beta.2' 10 | 11 | gem 'bootsnap', '>= 1.4.2', require: false 12 | 13 | group :development do 14 | gem 'spring' 15 | gem 'spring-watcher-listen', '~> 2.0.0' 16 | end 17 | 18 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 19 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 20 | 21 | group :development, :test do 22 | gem 'prettier' 23 | gem 'rspec-rails' 24 | end 25 | 26 | group :test do 27 | gem 'database_cleaner-active_record' 28 | gem 'database_cleaner-redis' 29 | end 30 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (6.1.1) 5 | actionpack (= 6.1.1) 6 | activesupport (= 6.1.1) 7 | nio4r (~> 2.0) 8 | websocket-driver (>= 0.6.1) 9 | actionmailbox (6.1.1) 10 | actionpack (= 6.1.1) 11 | activejob (= 6.1.1) 12 | activerecord (= 6.1.1) 13 | activestorage (= 6.1.1) 14 | activesupport (= 6.1.1) 15 | mail (>= 2.7.1) 16 | actionmailer (6.1.1) 17 | actionpack (= 6.1.1) 18 | actionview (= 6.1.1) 19 | activejob (= 6.1.1) 20 | activesupport (= 6.1.1) 21 | mail (~> 2.5, >= 2.5.4) 22 | rails-dom-testing (~> 2.0) 23 | actionpack (6.1.1) 24 | actionview (= 6.1.1) 25 | activesupport (= 6.1.1) 26 | rack (~> 2.0, >= 2.0.9) 27 | rack-test (>= 0.6.3) 28 | rails-dom-testing (~> 2.0) 29 | rails-html-sanitizer (~> 1.0, >= 1.2.0) 30 | actiontext (6.1.1) 31 | actionpack (= 6.1.1) 32 | activerecord (= 6.1.1) 33 | activestorage (= 6.1.1) 34 | activesupport (= 6.1.1) 35 | nokogiri (>= 1.8.5) 36 | actionview (6.1.1) 37 | activesupport (= 6.1.1) 38 | builder (~> 3.1) 39 | erubi (~> 1.4) 40 | rails-dom-testing (~> 2.0) 41 | rails-html-sanitizer (~> 1.1, >= 1.2.0) 42 | activejob (6.1.1) 43 | activesupport (= 6.1.1) 44 | globalid (>= 0.3.6) 45 | activemodel (6.1.1) 46 | activesupport (= 6.1.1) 47 | activerecord (6.1.1) 48 | activemodel (= 6.1.1) 49 | activesupport (= 6.1.1) 50 | activestorage (6.1.1) 51 | actionpack (= 6.1.1) 52 | activejob (= 6.1.1) 53 | activerecord (= 6.1.1) 54 | activesupport (= 6.1.1) 55 | marcel (~> 0.3.1) 56 | mimemagic (~> 0.3.2) 57 | activesupport (6.1.1) 58 | concurrent-ruby (~> 1.0, >= 1.0.2) 59 | i18n (>= 1.6, < 2) 60 | minitest (>= 5.1) 61 | tzinfo (~> 2.0) 62 | zeitwerk (~> 2.3) 63 | bootsnap (1.5.1) 64 | msgpack (~> 1.0) 65 | builder (3.2.4) 66 | concurrent-ruby (1.1.7) 67 | crass (1.0.6) 68 | database_cleaner (1.8.5) 69 | database_cleaner-active_record (1.8.0) 70 | activerecord 71 | database_cleaner (~> 1.8.0) 72 | database_cleaner-redis (1.8.0) 73 | database_cleaner (~> 1.8.0) 74 | redis 75 | diff-lcs (1.4.4) 76 | erubi (1.10.0) 77 | ffi (1.14.2) 78 | globalid (0.4.2) 79 | activesupport (>= 4.2.0) 80 | i18n (1.8.7) 81 | concurrent-ruby (~> 1.0) 82 | listen (3.4.0) 83 | rb-fsevent (~> 0.10, >= 0.10.3) 84 | rb-inotify (~> 0.9, >= 0.9.10) 85 | loofah (2.8.0) 86 | crass (~> 1.0.2) 87 | nokogiri (>= 1.5.9) 88 | mail (2.7.1) 89 | mini_mime (>= 0.1.1) 90 | marcel (0.3.3) 91 | mimemagic (~> 0.3.2) 92 | method_source (1.0.0) 93 | mimemagic (0.3.5) 94 | mini_mime (1.0.2) 95 | mini_portile2 (2.5.0) 96 | minitest (5.14.3) 97 | msgpack (1.3.3) 98 | nio4r (2.5.4) 99 | nokogiri (1.11.1) 100 | mini_portile2 (~> 2.5.0) 101 | racc (~> 1.4) 102 | pg (1.2.3) 103 | prettier (1.3.0) 104 | puma (5.1.1) 105 | nio4r (~> 2.0) 106 | racc (1.5.2) 107 | rack (2.2.3) 108 | rack-proxy (0.6.5) 109 | rack 110 | rack-test (1.1.0) 111 | rack (>= 1.0, < 3) 112 | rails (6.1.1) 113 | actioncable (= 6.1.1) 114 | actionmailbox (= 6.1.1) 115 | actionmailer (= 6.1.1) 116 | actionpack (= 6.1.1) 117 | actiontext (= 6.1.1) 118 | actionview (= 6.1.1) 119 | activejob (= 6.1.1) 120 | activemodel (= 6.1.1) 121 | activerecord (= 6.1.1) 122 | activestorage (= 6.1.1) 123 | activesupport (= 6.1.1) 124 | bundler (>= 1.15.0) 125 | railties (= 6.1.1) 126 | sprockets-rails (>= 2.0.0) 127 | rails-dom-testing (2.0.3) 128 | activesupport (>= 4.2.0) 129 | nokogiri (>= 1.6) 130 | rails-html-sanitizer (1.3.0) 131 | loofah (~> 2.3) 132 | railties (6.1.1) 133 | actionpack (= 6.1.1) 134 | activesupport (= 6.1.1) 135 | method_source 136 | rake (>= 0.8.7) 137 | thor (~> 1.0) 138 | rake (13.0.3) 139 | rb-fsevent (0.10.4) 140 | rb-inotify (0.10.1) 141 | ffi (~> 1.0) 142 | redis (4.2.5) 143 | rspec-core (3.10.1) 144 | rspec-support (~> 3.10.0) 145 | rspec-expectations (3.10.1) 146 | diff-lcs (>= 1.2.0, < 2.0) 147 | rspec-support (~> 3.10.0) 148 | rspec-mocks (3.10.1) 149 | diff-lcs (>= 1.2.0, < 2.0) 150 | rspec-support (~> 3.10.0) 151 | rspec-rails (4.0.2) 152 | actionpack (>= 4.2) 153 | activesupport (>= 4.2) 154 | railties (>= 4.2) 155 | rspec-core (~> 3.10) 156 | rspec-expectations (~> 3.10) 157 | rspec-mocks (~> 3.10) 158 | rspec-support (~> 3.10) 159 | rspec-support (3.10.1) 160 | semantic_range (2.3.1) 161 | spring (2.1.1) 162 | spring-watcher-listen (2.0.1) 163 | listen (>= 2.7, < 4.0) 164 | spring (>= 1.2, < 3.0) 165 | sprockets (4.0.2) 166 | concurrent-ruby (~> 1.0) 167 | rack (> 1, < 3) 168 | sprockets-rails (3.2.2) 169 | actionpack (>= 4.0) 170 | activesupport (>= 4.0) 171 | sprockets (>= 3.0.0) 172 | thor (1.0.1) 173 | tzinfo (2.0.4) 174 | concurrent-ruby (~> 1.0) 175 | webpacker (6.0.0.beta.2) 176 | activesupport (>= 5.2) 177 | rack-proxy (>= 0.6.1) 178 | railties (>= 5.2) 179 | semantic_range (>= 2.3.0) 180 | websocket-driver (0.7.3) 181 | websocket-extensions (>= 0.1.0) 182 | websocket-extensions (0.1.5) 183 | zeitwerk (2.4.2) 184 | 185 | PLATFORMS 186 | ruby 187 | 188 | DEPENDENCIES 189 | bootsnap (>= 1.4.2) 190 | database_cleaner-active_record 191 | database_cleaner-redis 192 | pg (>= 0.18, < 2.0) 193 | prettier 194 | puma (~> 5) 195 | rails (~> 6.1.1) 196 | rspec-rails 197 | spring 198 | spring-watcher-listen (~> 2.0.0) 199 | tzinfo-data 200 | webpacker (= 6.0.0.beta.2) 201 | 202 | RUBY VERSION 203 | ruby 2.7.2p137 204 | 205 | BUNDLED WITH 206 | 2.1.4 207 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development} 2 | -------------------------------------------------------------------------------- /Procfile.dev: -------------------------------------------------------------------------------- 1 | web: bundle exec puma -p 3000 2 | webpack: bin/webpack-dev-server 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rails + Vue.js SPA-ish Template 2 | 3 | A simple template for creating a Vue.js single page application inside Rails using Webpacker along with a Rails API. 4 | 5 | Mainly used for my own personal projects, so please remove/adapt things as you need. 6 | 7 | ### Why not a "real" SPA? 8 | 9 | For me, having a single application to deploy and maintain reduces the complexity a lot. You get most of the benefits of running an SPA this way, plus the power of Rails for your API. 10 | 11 | ### Technology Used 12 | 13 | - Rails 14 | - RSpec 15 | - ESLint 16 | - Axios 17 | - Vue.js 18 | - Vue Router 19 | - Typescript 20 | - Tailwind CSS 21 | 22 | ### Also sets up 23 | 24 | - An example Dockerfile, based on alpine to keep the size down 25 | - Dependabot for Bundler and Yarn 26 | - Github actions 27 | - Run RSpec 28 | - Run ESLint 29 | - Build Docker image 30 | - Push Docker image to Github Container Registry (Optional - See below) 31 | 32 | #### Github Container Registry 33 | 34 | By default, this repo will just build the Docker image in Github Actions, but it will not push it anywhere. 35 | 36 | To push these images to the Github Container Registry, please do the following: 37 | 38 | - Head over to [Personal access tokens](https://github.com/settings/tokens), and create a token with `write:packages` permissions. 39 | - Edit this repository, and got to Secrets 40 | - Add the token from step one with the key `GHCR_TOKEN` 41 | - Now each time you push to master, an image will be built, tagged with that commit hash, and pushed to Github Container Registry. 42 | 43 | ### Structure 44 | 45 | There is a single Rails ERB file, which is the entrypoint into Vue.js. It lives in [`app/views/application/index.html.erb`](https://github.com/scottrobertson/rails-vue-template/blob/master/app/views/application/index.html.erb). All other view rendering is handled by Vue.js. 46 | 47 | Inside that ERB file, we load [`app/javascript/packs/application.ts`](https://github.com/scottrobertson/rails-vue-template/blob/master/app/javascript/packs/application.ts), which loads Vue.js, and delegates all routing to vue-router, with all the routes being defined in [`app/javascript/routes.ts`](https://github.com/scottrobertson/rails-vue-template/blob/master/app/javascript/routes.ts). 48 | 49 | The Rails API lives in an `api` route namespace, and everything else is [delegated to vue-router](https://github.com/scottrobertson/rails-vue-template/blob/master/config/routes.rb#L10). This allows you to build a full single page application, while having the power of Rails available for your API etc. 50 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/app/assets/images/.keep -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base; end 3 | end 4 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base; end 3 | end 4 | -------------------------------------------------------------------------------- /app/controllers/api/base_controller.rb: -------------------------------------------------------------------------------- 1 | module Api 2 | class BaseController < ActionController::API; end 3 | end 4 | -------------------------------------------------------------------------------- /app/controllers/api/home_controller.rb: -------------------------------------------------------------------------------- 1 | module Api 2 | class HomeController < BaseController 3 | def index 4 | render json: { ok: true } 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/controllers/api/posts_controller.rb: -------------------------------------------------------------------------------- 1 | module Api 2 | class PostsController < BaseController 3 | def index 4 | # An example API endpoint to return a list of posts. 5 | # Here we just call an external placeholder API to get some posts. 6 | # In reality, you would get them from your database or something. 7 | net = Net::HTTP.new('jsonplaceholder.typicode.com', 443) 8 | net.use_ssl = true 9 | response = net.get('/posts') 10 | posts = JSON.parse(response.response.body).shuffle 11 | 12 | render json: posts 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | def index 3 | render 'index' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper; end 2 | -------------------------------------------------------------------------------- /app/javascript/axios_client.ts: -------------------------------------------------------------------------------- 1 | import VueAxios from "vue-axios"; 2 | import Vue from "vue"; 3 | import axios from "axios"; 4 | 5 | const token = document.getElementsByName("csrf-token")[0].getAttribute("content"); 6 | axios.defaults.headers.common["X-CSRF-Token"] = token; 7 | 8 | Vue.use(VueAxios, axios); 9 | 10 | export default axios; 11 | -------------------------------------------------------------------------------- /app/javascript/components/layout.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 34 | -------------------------------------------------------------------------------- /app/javascript/components/post.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 23 | -------------------------------------------------------------------------------- /app/javascript/packs/application.ts: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | 3 | import router from "../routes"; 4 | import Layout from "../components/layout.vue"; 5 | 6 | import "../axios_client"; 7 | 8 | import "../stylesheets/application.css"; 9 | 10 | document.addEventListener("DOMContentLoaded", () => { 11 | const app = new Vue({ 12 | render: (h) => h(Layout), 13 | router, 14 | }).$mount(); 15 | 16 | document.body.appendChild(app.$el); 17 | }); 18 | -------------------------------------------------------------------------------- /app/javascript/pages/errors/404.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | -------------------------------------------------------------------------------- /app/javascript/pages/home/index.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 53 | -------------------------------------------------------------------------------- /app/javascript/pages/privacy/index.vue: -------------------------------------------------------------------------------- 1 | 32 | 33 | 38 | -------------------------------------------------------------------------------- /app/javascript/routes.ts: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import VueRouter from "vue-router"; 3 | 4 | import PageNotFound from "./pages/errors/404.vue"; 5 | import HomeIndex from "./pages/home/index.vue"; 6 | import PrivacyIndex from "./pages/privacy/index.vue"; 7 | 8 | Vue.use(VueRouter); 9 | 10 | const router = new VueRouter({ 11 | mode: "history", 12 | routes: [ 13 | { path: "/", component: HomeIndex }, 14 | { path: "/privacy", component: PrivacyIndex }, 15 | { path: "*", component: PageNotFound }, 16 | ], 17 | }); 18 | 19 | export default router; 20 | -------------------------------------------------------------------------------- /app/javascript/shims/vue.shim.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.vue" { 2 | import Vue from "vue"; 3 | 4 | export default Vue; 5 | } 6 | -------------------------------------------------------------------------------- /app/javascript/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | body { 6 | @apply font-sans; 7 | @apply antialiased; 8 | } 9 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | # Most jobs are safe to ignore if the underlying records are no longer available 5 | # discard_on ActiveJob::DeserializationError 6 | end 7 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/views/application/index.html.erb: -------------------------------------------------------------------------------- 1 | <%= stylesheet_packs_with_chunks_tag 'application' %> 2 | <%= javascript_packs_with_chunks_tag 'application' %> 3 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rails Template 5 | <%= csrf_meta_tags %> 6 | <%= csp_meta_tag %> 7 | 8 | 9 | 10 | 11 | 12 | <%= yield %> 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'bundle' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require "rubygems" 12 | 13 | m = Module.new do 14 | module_function 15 | 16 | def invoked_as_script? 17 | File.expand_path($0) == File.expand_path(__FILE__) 18 | end 19 | 20 | def env_var_version 21 | ENV["BUNDLER_VERSION"] 22 | end 23 | 24 | def cli_arg_version 25 | return unless invoked_as_script? # don't want to hijack other binstubs 26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` 27 | bundler_version = nil 28 | update_index = nil 29 | ARGV.each_with_index do |a, i| 30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN 31 | bundler_version = a 32 | end 33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 34 | bundler_version = $1 || ">= 0.a" 35 | update_index = i 36 | end 37 | bundler_version 38 | end 39 | 40 | def gemfile 41 | gemfile = ENV["BUNDLE_GEMFILE"] 42 | return gemfile if gemfile && !gemfile.empty? 43 | 44 | File.expand_path("../../Gemfile", __FILE__) 45 | end 46 | 47 | def lockfile 48 | lockfile = 49 | case File.basename(gemfile) 50 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) 51 | else "#{gemfile}.lock" 52 | end 53 | File.expand_path(lockfile) 54 | end 55 | 56 | def lockfile_version 57 | return unless File.file?(lockfile) 58 | lockfile_contents = File.read(lockfile) 59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 60 | Regexp.last_match(1) 61 | end 62 | 63 | def bundler_version 64 | @bundler_version ||= begin 65 | env_var_version || cli_arg_version || 66 | lockfile_version || "#{Gem::Requirement.default}.a" 67 | end 68 | end 69 | 70 | def load_bundler! 71 | ENV["BUNDLE_GEMFILE"] ||= gemfile 72 | 73 | # must dup string for RG < 1.8 compatibility 74 | activate_bundler(bundler_version.dup) 75 | end 76 | 77 | def activate_bundler(bundler_version) 78 | if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0") 79 | bundler_version = "< 2" 80 | end 81 | gem_error = activation_error_handling do 82 | gem "bundler", bundler_version 83 | end 84 | return if gem_error.nil? 85 | require_error = activation_error_handling do 86 | require "bundler/version" 87 | end 88 | return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION)) 89 | warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`" 90 | exit 42 91 | end 92 | 93 | def activation_error_handling 94 | yield 95 | nil 96 | rescue StandardError, LoadError => e 97 | e 98 | end 99 | end 100 | 101 | m.load_bundler! 102 | 103 | if m.invoked_as_script? 104 | load Gem.bin_path("bundler", "bundle") 105 | end 106 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | load File.expand_path("spring", __dir__) 3 | APP_PATH = File.expand_path('../config/application', __dir__) 4 | require_relative "../config/boot" 5 | require "rails/commands" 6 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | load File.expand_path("spring", __dir__) 3 | require_relative "../config/boot" 4 | require "rake" 5 | Rake.application.run 6 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "fileutils" 3 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path('..', __dir__) 6 | 7 | def system!(*args) 8 | system(*args) || abort("\n== Command #{args} failed ==") 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to set up or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies 21 | system! 'bin/yarn' 22 | 23 | # puts "\n== Copying sample files ==" 24 | # unless File.exist?('config/database.yml') 25 | # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' 26 | # end 27 | 28 | puts "\n== Preparing database ==" 29 | system! 'bin/rails db:prepare' 30 | 31 | puts "\n== Removing old logs and tempfiles ==" 32 | system! 'bin/rails log:clear tmp:clear' 33 | 34 | puts "\n== Restarting application server ==" 35 | system! 'bin/rails restart' 36 | end 37 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"]) 3 | # Load Spring without loading other gems in the Gemfile, for speed. 4 | require "bundler" 5 | Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring| 6 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 7 | gem "spring", spring.version 8 | require "spring/binstub" 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /bin/webpack: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" 4 | ENV["NODE_ENV"] ||= "development" 5 | 6 | require "pathname" 7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 8 | Pathname.new(__FILE__).realpath) 9 | 10 | require "bundler/setup" 11 | 12 | require "webpacker" 13 | require "webpacker/webpack_runner" 14 | 15 | APP_ROOT = File.expand_path("..", __dir__) 16 | Dir.chdir(APP_ROOT) do 17 | Webpacker::WebpackRunner.run(ARGV) 18 | end 19 | -------------------------------------------------------------------------------- /bin/webpack-dev-server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" 4 | ENV["NODE_ENV"] ||= "development" 5 | 6 | require "pathname" 7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 8 | Pathname.new(__FILE__).realpath) 9 | 10 | require "bundler/setup" 11 | 12 | require "webpacker" 13 | require "webpacker/dev_server_runner" 14 | 15 | APP_ROOT = File.expand_path("..", __dir__) 16 | Dir.chdir(APP_ROOT) do 17 | Webpacker::DevServerRunner.run(ARGV) 18 | end 19 | -------------------------------------------------------------------------------- /bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | 4 | APP_ROOT = File.expand_path('..', __dir__) 5 | Dir.chdir(APP_ROOT) do 6 | executable_path = ENV["PATH"].split(File::PATH_SEPARATOR).find do |path| 7 | normalized_path = File.expand_path(path) 8 | 9 | normalized_path != __dir__ && File.executable?(Pathname.new(normalized_path).join('yarn')) 10 | end 11 | 12 | if executable_path 13 | exec File.expand_path(Pathname.new(executable_path).join('yarn')), *ARGV 14 | else 15 | $stderr.puts "Yarn executable was not detected in the system." 16 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" 17 | exit 1 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative "boot" 2 | 3 | require "rails/all" 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module VueTemplate 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 6.0 13 | 14 | # Configuration for the application, engines, and railties goes here. 15 | # 16 | # These settings can be overridden in specific environments using the files 17 | # in config/environments, which are processed later. 18 | # 19 | # config.time_zone = "Central Time (US & Canada)" 20 | # config.eager_load_paths << Rails.root.join("extras") 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require "bundler/setup" # Set up gems listed in the Gemfile. 4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: vue_template_production 11 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | default: &default 2 | adapter: postgresql 3 | encoding: unicode 4 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 5 | # prepared_statements: false # Disable this if you use PGBouncer 6 | 7 | development: 8 | <<: *default 9 | database: rails_vue_template_development 10 | 11 | test: 12 | <<: *default 13 | database: rails_vue_template_development 14 | url: <%= ENV['DATABASE_URL'] %> 15 | 16 | production: 17 | <<: *default 18 | url: <%= ENV['DATABASE_URL'] %> 19 | 20 | staging: 21 | <<: *default 22 | url: <%= ENV['DATABASE_URL'] %> 23 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # In the development environment your application's code is reloaded any time 7 | # it changes. This slows down response time but is perfect for development 8 | # since you don't have to restart the web server when you make code changes. 9 | config.cache_classes = false 10 | 11 | # Do not eager load code on boot. 12 | config.eager_load = false 13 | 14 | # Show full error reports. 15 | config.consider_all_requests_local = true 16 | 17 | # Enable/disable caching. By default caching is disabled. 18 | # Run rails dev:cache to toggle caching. 19 | if Rails.root.join('tmp', 'caching-dev.txt').exist? 20 | config.action_controller.perform_caching = true 21 | config.action_controller.enable_fragment_cache_logging = true 22 | 23 | config.cache_store = :memory_store 24 | config.public_file_server.headers = { 25 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 26 | } 27 | else 28 | config.action_controller.perform_caching = false 29 | 30 | config.cache_store = :null_store 31 | end 32 | 33 | # Store uploaded files on the local file system (see config/storage.yml for options). 34 | config.active_storage.service = :local 35 | 36 | # Don't care if the mailer can't send. 37 | config.action_mailer.raise_delivery_errors = false 38 | 39 | config.action_mailer.perform_caching = false 40 | 41 | # Print deprecation notices to the Rails logger. 42 | config.active_support.deprecation = :log 43 | 44 | # Raise exceptions for disallowed deprecations. 45 | config.active_support.disallowed_deprecation = :raise 46 | 47 | # Tell Active Support which deprecation messages to disallow. 48 | config.active_support.disallowed_deprecation_warnings = [] 49 | 50 | # Raise an error on page load if there are pending migrations. 51 | config.active_record.migration_error = :page_load 52 | 53 | # Highlight code that triggered database queries in logs. 54 | config.active_record.verbose_query_logs = true 55 | 56 | # Debug mode disables concatenation and preprocessing of assets. 57 | # This option may cause significant delays in view rendering with a large 58 | # number of complex assets. 59 | config.assets.debug = true 60 | 61 | # Suppress logger output for asset requests. 62 | config.assets.quiet = true 63 | 64 | # Raises error for missing translations. 65 | # config.i18n.raise_on_missing_translations = true 66 | 67 | # Annotate rendered view with file names. 68 | # config.action_view.annotate_rendered_view_with_filenames = true 69 | 70 | # Use an evented file watcher to asynchronously detect changes in source code, 71 | # routes, locales, etc. This feature depends on the listen gem. 72 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 73 | 74 | # Uncomment if you wish to allow Action Cable access from any origin. 75 | # config.action_cable.disable_request_forgery_protection = true 76 | end 77 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # Code is not reloaded between requests. 7 | config.cache_classes = true 8 | 9 | # Eager load code on boot. This eager loads most of Rails and 10 | # your application in memory, allowing both threaded web servers 11 | # and those relying on copy on write to perform better. 12 | # Rake tasks automatically ignore this option for performance. 13 | config.eager_load = true 14 | 15 | # Full error reports are disabled and caching is turned on. 16 | config.consider_all_requests_local = false 17 | config.action_controller.perform_caching = true 18 | 19 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 20 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 21 | # config.require_master_key = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 26 | 27 | # Compress CSS using a preprocessor. 28 | # config.assets.css_compressor = :sass 29 | 30 | # Do not fallback to assets pipeline if a precompiled asset is missed. 31 | config.assets.compile = false 32 | 33 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 34 | # config.asset_host = 'http://assets.example.com' 35 | 36 | # Specifies the header that your server uses for sending files. 37 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 38 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 39 | 40 | # Store uploaded files on the local file system (see config/storage.yml for options). 41 | config.active_storage.service = :local 42 | 43 | # Mount Action Cable outside main process or domain. 44 | # config.action_cable.mount_path = nil 45 | # config.action_cable.url = 'wss://example.com/cable' 46 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 47 | 48 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 49 | # config.force_ssl = true 50 | 51 | # Include generic and useful information about system operation, but avoid logging too much 52 | # information to avoid inadvertent exposure of personally identifiable information (PII). 53 | config.log_level = :info 54 | 55 | # Prepend all log lines with the following tags. 56 | config.log_tags = [ :request_id ] 57 | 58 | # Use a different cache store in production. 59 | # config.cache_store = :mem_cache_store 60 | 61 | # Use a real queuing backend for Active Job (and separate queues per environment). 62 | # config.active_job.queue_adapter = :resque 63 | # config.active_job.queue_name_prefix = "vue_template_production" 64 | 65 | config.action_mailer.perform_caching = false 66 | 67 | # Ignore bad email addresses and do not raise email delivery errors. 68 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 69 | # config.action_mailer.raise_delivery_errors = false 70 | 71 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 72 | # the I18n.default_locale when a translation cannot be found). 73 | config.i18n.fallbacks = true 74 | 75 | # Send deprecation notices to registered listeners. 76 | config.active_support.deprecation = :notify 77 | 78 | # Log disallowed deprecations. 79 | config.active_support.disallowed_deprecation = :log 80 | 81 | # Tell Active Support which deprecation messages to disallow. 82 | config.active_support.disallowed_deprecation_warnings = [] 83 | 84 | # Use default logging formatter so that PID and timestamp are not suppressed. 85 | config.log_formatter = ::Logger::Formatter.new 86 | 87 | # Use a different logger for distributed setups. 88 | # require "syslog/logger" 89 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 90 | 91 | if ENV["RAILS_LOG_TO_STDOUT"].present? 92 | logger = ActiveSupport::Logger.new(STDOUT) 93 | logger.formatter = config.log_formatter 94 | config.logger = ActiveSupport::TaggedLogging.new(logger) 95 | end 96 | 97 | # Do not dump schema after migrations. 98 | config.active_record.dump_schema_after_migration = false 99 | 100 | # Inserts middleware to perform automatic connection switching. 101 | # The `database_selector` hash is used to pass options to the DatabaseSelector 102 | # middleware. The `delay` is used to determine how long to wait after a write 103 | # to send a subsequent read to the primary. 104 | # 105 | # The `database_resolver` class is used by the middleware to determine which 106 | # database is appropriate to use based on the time delay. 107 | # 108 | # The `database_resolver_context` class is used by the middleware to set 109 | # timestamps for the last write to the primary. The resolver uses the context 110 | # class timestamps to determine how long to wait before reading from the 111 | # replica. 112 | # 113 | # By default Rails will store a last write timestamp in the session. The 114 | # DatabaseSelector middleware is designed as such you can define your own 115 | # strategy for connection switching and pass that into the middleware through 116 | # these configuration options. 117 | # config.active_record.database_selector = { delay: 2.seconds } 118 | # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver 119 | # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session 120 | end 121 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | # The test environment is used exclusively to run your application's 4 | # test suite. You never need to work with it otherwise. Remember that 5 | # your test database is "scratch space" for the test suite and is wiped 6 | # and recreated between test runs. Don't rely on the data there! 7 | 8 | Rails.application.configure do 9 | # Settings specified here will take precedence over those in config/application.rb. 10 | 11 | config.cache_classes = false 12 | config.action_view.cache_template_loading = true 13 | 14 | # Do not eager load code on boot. This avoids loading your whole application 15 | # just for the purpose of running a single test. If you are using a tool that 16 | # preloads Rails for running tests, you may have to set it to true. 17 | config.eager_load = false 18 | 19 | # Configure public file server for tests with Cache-Control for performance. 20 | config.public_file_server.enabled = true 21 | config.public_file_server.headers = { 22 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 23 | } 24 | 25 | # Show full error reports and disable caching. 26 | config.consider_all_requests_local = true 27 | config.action_controller.perform_caching = false 28 | config.cache_store = :null_store 29 | 30 | # Raise exceptions instead of rendering exception templates. 31 | config.action_dispatch.show_exceptions = false 32 | 33 | # Disable request forgery protection in test environment. 34 | config.action_controller.allow_forgery_protection = false 35 | 36 | # Store uploaded files on the local file system in a temporary directory. 37 | config.active_storage.service = :test 38 | 39 | config.action_mailer.perform_caching = false 40 | 41 | # Tell Action Mailer not to deliver emails to the real world. 42 | # The :test delivery method accumulates sent emails in the 43 | # ActionMailer::Base.deliveries array. 44 | config.action_mailer.delivery_method = :test 45 | 46 | # Print deprecation notices to the stderr. 47 | config.active_support.deprecation = :stderr 48 | 49 | # Raise exceptions for disallowed deprecations. 50 | config.active_support.disallowed_deprecation = :raise 51 | 52 | # Tell Active Support which deprecation messages to disallow. 53 | config.active_support.disallowed_deprecation_warnings = [] 54 | 55 | # Raises error for missing translations. 56 | # config.i18n.raise_on_missing_translations = true 57 | 58 | # Annotate rendered view with file names. 59 | # config.action_view.annotate_rendered_view_with_filenames = true 60 | end 61 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ActiveSupport::Reloader.to_prepare do 4 | # ApplicationController.renderer.defaults.merge!( 5 | # http_host: 'example.org', 6 | # https: false 7 | # ) 8 | # end 9 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | # Add Yarn node_modules folder to the asset load path. 9 | Rails.application.config.assets.paths << Rails.root.join('node_modules') 10 | 11 | # Precompile additional assets. 12 | # application.js, application.css, and all non-JS/CSS in the app/assets 13 | # folder are already added. 14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 15 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code 7 | # by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'". 8 | Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"] 9 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy 4 | # For further information see the following documentation 5 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy 6 | 7 | # Rails.application.config.content_security_policy do |policy| 8 | # policy.default_src :self, :https 9 | # policy.font_src :self, :https, :data 10 | # policy.img_src :self, :https, :data 11 | # policy.object_src :none 12 | # policy.script_src :self, :https 13 | # policy.style_src :self, :https 14 | # # If you are using webpack-dev-server then specify webpack-dev-server host 15 | # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? 16 | 17 | # # Specify URI for violation reports 18 | # # policy.report_uri "/csp-violation-report-endpoint" 19 | # end 20 | 21 | # If you are using UJS then enable automatic nonce generation 22 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } 23 | 24 | # Set the nonce only to specific directives 25 | # Rails.application.config.content_security_policy_nonce_directives = %w(script-src) 26 | 27 | # Report CSP violations to a specified URI 28 | # For further information see the following documentation: 29 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only 30 | # Rails.application.config.content_security_policy_report_only = true 31 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [ 5 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn 6 | ] 7 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /config/initializers/new_framework_defaults_6_1.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.1 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 | # Support for inversing belongs_to -> has_many Active Record associations. 10 | # Rails.application.config.active_record.has_many_inversing = true 11 | 12 | # Track Active Storage variants in the database. 13 | # Rails.application.config.active_storage.track_variants = true 14 | 15 | # Apply random variation to the delay when retrying failed jobs. 16 | # Rails.application.config.active_job.retry_jitter = 0.15 17 | 18 | # Stop executing `after_enqueue`/`after_perform` callbacks if 19 | # `before_enqueue`/`before_perform` respectively halts with `throw :abort`. 20 | # Rails.application.config.active_job.skip_after_callbacks_if_terminated = true 21 | 22 | # Specify cookies SameSite protection level: either :none, :lax, or :strict. 23 | # 24 | # This change is not backwards compatible with earlier Rails versions. 25 | # It's best enabled when your entire app is migrated and stable on 6.1. 26 | # Rails.application.config.action_dispatch.cookies_same_site_protection = :lax 27 | 28 | # Generate CSRF tokens that are encoded in URL-safe Base64. 29 | # 30 | # This change is not backwards compatible with earlier Rails versions. 31 | # It's best enabled when your entire app is migrated and stable on 6.1. 32 | # Rails.application.config.action_controller.urlsafe_csrf_tokens = true 33 | 34 | # Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an 35 | # UTC offset or a UTC time. 36 | # ActiveSupport.utc_to_local_returns_utc_offset_times = true 37 | 38 | # Change the default HTTP status code to `308` when redirecting non-GET/HEAD 39 | # requests to HTTPS in `ActionDispatch::SSL` middleware. 40 | # Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 41 | 42 | # Use new connection handling API. For most applications this won't have any 43 | # effect. For applications using multiple databases, this new API provides 44 | # support for granular connection swapping. 45 | # Rails.application.config.active_record.legacy_connection_handling = false 46 | 47 | # Make `form_with` generate non-remote forms by default. 48 | # Rails.application.config.action_view.form_with_generates_remote_forms = false 49 | 50 | # Set the default queue name for the analysis job to the queue adapter default. 51 | # Rails.application.config.active_storage.queues.analysis = nil 52 | 53 | # Set the default queue name for the purge job to the queue adapter default. 54 | # Rails.application.config.active_storage.queues.purge = nil 55 | 56 | # Set the default queue name for the incineration job to the queue adapter default. 57 | # Rails.application.config.action_mailbox.queues.incineration = nil 58 | 59 | # Set the default queue name for the routing job to the queue adapter default. 60 | # Rails.application.config.action_mailbox.queues.routing = nil 61 | 62 | # Set the default queue name for the mail deliver job to the queue adapter default. 63 | # Rails.application.config.action_mailer.deliver_later_queue_name = nil 64 | -------------------------------------------------------------------------------- /config/initializers/permissions_policy.rb: -------------------------------------------------------------------------------- 1 | # Define an application-wide HTTP permissions policy. For further 2 | # information see https://developers.google.com/web/updates/2018/06/feature-policy 3 | # 4 | # Rails.application.config.permissions_policy do |f| 5 | # f.camera :none 6 | # f.gyroscope :none 7 | # f.microphone :none 8 | # f.usb :none 9 | # f.fullscreen :self 10 | # f.payment :self, "https://secure.example.com" 11 | # end 12 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # 'true': 'foo' 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at https://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } 9 | threads min_threads_count, max_threads_count 10 | 11 | # Specifies the `worker_timeout` threshold that Puma will use to wait before 12 | # terminating a worker in development environments. 13 | # 14 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" 15 | 16 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 17 | # 18 | port ENV.fetch("PORT") { 3000 } 19 | 20 | # Specifies the `environment` that Puma will run in. 21 | # 22 | environment ENV.fetch("RAILS_ENV") { "development" } 23 | 24 | # Specifies the `pidfile` that Puma will use. 25 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 26 | 27 | # Specifies the number of `workers` to boot in clustered mode. 28 | # Workers are forked web server processes. If using threads and workers together 29 | # the concurrency of the application would be max `threads` * `workers`. 30 | # Workers do not work on JRuby or Windows (both of which do not support 31 | # processes). 32 | # 33 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 34 | 35 | # Use the `preload_app!` method when specifying a `workers` number. 36 | # This directive tells Puma to first boot the application and load code 37 | # before forking the application. This takes advantage of Copy On Write 38 | # process behavior so workers use less memory. 39 | # 40 | # preload_app! 41 | 42 | # Allow puma to be restarted by `rails restart` command. 43 | plugin :tmp_restart 44 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | 3 | root to: 'application#index' 4 | 5 | namespace :api, :defaults => { :format => 'json' } do 6 | root to: 'home#index' 7 | resources :posts 8 | end 9 | 10 | match "*path", to: "application#index", format: false, via: :get 11 | end 12 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | Spring.watch( 2 | ".ruby-version", 3 | ".rbenv-vars", 4 | "tmp/restart.txt", 5 | "tmp/caching-dev.txt" 6 | ) 7 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket 23 | 24 | # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /config/webpack/base.js: -------------------------------------------------------------------------------- 1 | const Webpacker = require("@rails/webpacker"); 2 | const vueConfig = require("./rules/vue"); 3 | 4 | // Disabling `optimization` because the Webpack chunks aren't getting executed. 5 | // That is, the HTML will load and the JavaScript is "pre-loaded" into "named 6 | // chunks" but those chunks are never executed, so the Vue app is never started. 7 | delete Webpacker.webpackConfig.optimization; 8 | 9 | const cssConfig = { 10 | resolve: { 11 | extensions: [".css"], 12 | }, 13 | }; 14 | 15 | // Merge vueConfig first: https://github.com/rails/webpacker/issues/2835#issuecomment-759772592 16 | module.exports = Webpacker.merge(vueConfig, Webpacker.webpackConfig, cssConfig); 17 | -------------------------------------------------------------------------------- /config/webpack/development.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || "development"; 2 | 3 | const webpackConfig = require("./base"); 4 | 5 | module.exports = webpackConfig; 6 | -------------------------------------------------------------------------------- /config/webpack/production.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || "production"; 2 | 3 | const webpackConfig = require("./base"); 4 | 5 | module.exports = webpackConfig; 6 | -------------------------------------------------------------------------------- /config/webpack/rules/vue.js: -------------------------------------------------------------------------------- 1 | const VueLoaderPlugin = require("vue-loader/lib/plugin"); 2 | 3 | // Ref: https://github.com/rails/webpacker#other-frameworks 4 | module.exports = { 5 | module: { 6 | rules: [ 7 | { 8 | test: /\.vue$/, 9 | use: { loader: "vue-loader" }, 10 | }, 11 | ], 12 | }, 13 | plugins: [new VueLoaderPlugin()], 14 | resolve: { 15 | alias: { 16 | vue: "vue/dist/vue.js", 17 | }, 18 | }, 19 | }; 20 | -------------------------------------------------------------------------------- /config/webpack/test.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || "development"; 2 | 3 | const webpackConfig = require("./base"); 4 | 5 | module.exports = webpackConfig; 6 | -------------------------------------------------------------------------------- /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 | webpack_compile_output: true 10 | 11 | # Additional paths webpack should lookup modules 12 | # ['app/assets', 'engine/foo/app/assets'] 13 | additional_paths: [] 14 | 15 | # Reload manifest.json on all requests so we reload latest compiled packs 16 | cache_manifest: false 17 | 18 | development: 19 | <<: *default 20 | compile: true 21 | 22 | # Reference: https://webpack.js.org/configuration/dev-server/ 23 | dev_server: 24 | https: false 25 | host: localhost 26 | port: 3035 27 | public: localhost:3035 28 | # Hot Module Replacement updates modules while the application is running without a full reload 29 | hmr: false 30 | # Inline should be set to true if using HMR; it inserts a script to take care of live reloading 31 | inline: true 32 | # Should we show a full-screen overlay in the browser when there are compiler errors or warnings? 33 | overlay: true 34 | # Should we use gzip compression? 35 | compress: true 36 | # Note that apps that do not check the host are vulnerable to DNS rebinding attacks 37 | disable_host_check: true 38 | # This option lets the browser open with your local IP 39 | use_local_ip: false 40 | # When enabled, nothing except the initial startup information will be written to the console. 41 | # This also means that errors or warnings from webpack are not visible. 42 | quiet: false 43 | pretty: false 44 | headers: 45 | 'Access-Control-Allow-Origin': '*' 46 | watch_options: 47 | ignored: '**/node_modules/**' 48 | 49 | test: 50 | <<: *default 51 | compile: true 52 | 53 | # Compile test packs to a separate directory 54 | public_output_path: packs-test 55 | 56 | production: 57 | <<: *default 58 | 59 | # Production depends on precompilation of packs prior to booting for performance. 60 | compile: false 61 | 62 | # Cache manifest.json for performance 63 | cache_manifest: true 64 | -------------------------------------------------------------------------------- /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: 0) do 14 | 15 | # These are extensions that must be enabled in order to support this database 16 | enable_extension "plpgsql" 17 | 18 | end 19 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 | # Character.create(name: 'Luke', movie: movies.first) 8 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/lib/tasks/.keep -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/log/.keep -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue_template", 3 | "private": true, 4 | "scripts": { 5 | "lint": "eslint --ext .js,.vue,.ts app/javascript" 6 | }, 7 | "dependencies": { 8 | "@babel/preset-typescript": "^7.12.7", 9 | "@rails/actioncable": "^6", 10 | "@rails/activestorage": "^6", 11 | "@rails/ujs": "^6", 12 | "@rails/webpacker": "^6.0.0-beta.2", 13 | "@typescript-eslint/eslint-plugin": "^4.5.0", 14 | "autoprefixer": "^10.0.4", 15 | "axios": "^0.21.0", 16 | "css-loader": "^5.0.1", 17 | "css-minimizer-webpack-plugin": "^1.2.0", 18 | "mini-css-extract-plugin": "^1.3.3", 19 | "path": "^0.12.7", 20 | "postcss": "^8.1.14", 21 | "postcss-loader": "^4.1.0", 22 | "tailwindcss": "^2.0.1", 23 | "turbolinks": "^5.2.0", 24 | "typescript": "^4.1.3", 25 | "vue": "^2.6.10", 26 | "vue-axios": "^3", 27 | "vue-loader": "^15.9.6", 28 | "vue-router": "^3.4.7", 29 | "vue-template-compiler": "^2.6.10", 30 | "webpack": "^5.11.0", 31 | "webpack-cli": "^4.2.0" 32 | }, 33 | "version": "0.1.0", 34 | "devDependencies": { 35 | "@prettier/plugin-ruby": "^1.3.0", 36 | "@types/node": "^14.14.5", 37 | "@typescript-eslint/parser": "^4.5.0", 38 | "@webpack-cli/serve": "^1.2.1", 39 | "babel-eslint": "^10.1.0", 40 | "babel-preset-typescript-vue": "^1.1.1", 41 | "eslint": "^7.17.0", 42 | "eslint-config-airbnb-base": "^14.2.1", 43 | "eslint-config-prettier": "^7.1.0", 44 | "eslint-import-resolver-webpack": "^0.13", 45 | "eslint-plugin-import": "^2.22.0", 46 | "eslint-plugin-prettier": "^3.3.1", 47 | "eslint-plugin-prettier-vue": "^2.1.1", 48 | "eslint-plugin-vue": "^7.4.1", 49 | "fork-ts-checker-webpack-plugin": "^6", 50 | "prettier": "^2.2.1", 51 | "webpack-dev-server": "^3.11.1" 52 | }, 53 | "babel": { 54 | "presets": [ 55 | "./node_modules/@rails/webpacker/package/babel/preset.js" 56 | ] 57 | }, 58 | "browserslist": [ 59 | "defaults" 60 | ] 61 | } 62 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

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

63 |
64 |

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

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

The change you wanted was rejected.

62 |

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

63 |
64 |

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

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

We're sorry, but something went wrong.

62 |
63 |

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

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/public/apple-touch-icon.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/public/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /spec/controllers/api/base_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | describe Api::BaseController do 4 | it { should be_a ActionController::API } 5 | end 6 | -------------------------------------------------------------------------------- /spec/controllers/api/home_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | describe Api::HomeController do 4 | it { should be_a Api::BaseController } 5 | end 6 | -------------------------------------------------------------------------------- /spec/controllers/api/posts_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | describe Api::PostsController do 4 | it { should be_a Api::BaseController } 5 | end 6 | -------------------------------------------------------------------------------- /spec/controllers/application_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | describe ApplicationController do 4 | it { should be_a ActionController::Base } 5 | end 6 | -------------------------------------------------------------------------------- /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 | # Add additional requires below this line. Rails is not loaded until this point! 9 | 10 | # Requires supporting ruby files with custom matchers and macros, etc, in 11 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 12 | # run as spec files by default. This means that files in spec/support that end 13 | # in _spec.rb will both be required and run as specs, causing the specs to be 14 | # run twice. It is recommended that you do not name files matching this glob to 15 | # end with _spec.rb. You can configure this pattern with the --pattern 16 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 17 | # 18 | # The following line is provided for convenience purposes. It has the downside 19 | # of increasing the boot-up time by auto-requiring all files in the support 20 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 21 | # require only the support files necessary. 22 | 23 | Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } 24 | 25 | # Checks for pending migrations and applies them before tests are run. 26 | # If you are not using ActiveRecord, you can remove these lines. 27 | begin 28 | ActiveRecord::Migration.maintain_test_schema! 29 | rescue ActiveRecord::PendingMigrationError => e 30 | puts e.to_s.strip 31 | exit 1 32 | end 33 | 34 | RSpec.configure do |config| 35 | config.include ApiHelpers, type: :request 36 | 37 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 38 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 39 | 40 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 41 | # examples within a transaction, remove the following line or assign false 42 | # instead of true. 43 | config.use_transactional_fixtures = true 44 | 45 | config.before(:suite) do 46 | DatabaseCleaner.strategy = :transaction 47 | DatabaseCleaner.clean_with(:truncation) 48 | end 49 | 50 | config.around(:each) do |example| 51 | DatabaseCleaner.cleaning do 52 | example.run 53 | end 54 | end 55 | 56 | # You can uncomment this line to turn off ActiveRecord support entirely. 57 | # config.use_active_record = false 58 | 59 | # RSpec Rails can automatically mix in different behaviours to your tests 60 | # based on their file location, for example enabling you to call `get` and 61 | # `post` in specs under `spec/controllers`. 62 | # 63 | # You can disable this behaviour by removing the line below, and instead 64 | # explicitly tag your specs with their type, e.g.: 65 | # 66 | # RSpec.describe UsersController, type: :controller do 67 | # # ... 68 | # end 69 | # 70 | # The different available types are documented in the features, such as in 71 | # https://relishapp.com/rspec/rspec-rails/docs 72 | config.infer_spec_type_from_file_location! 73 | 74 | # Filter lines from Rails gems in backtraces. 75 | config.filter_rails_from_backtrace! 76 | # arbitrary gems may also be filtered via: 77 | # config.filter_gems_from_backtrace("gem name") 78 | end 79 | -------------------------------------------------------------------------------- /spec/request/api/posts_spec.rb: -------------------------------------------------------------------------------- 1 | RSpec.describe "api/posts", type: :request do 2 | describe "request list of all posts" do 3 | it 'returns a list of posts' do 4 | get '/api/posts' 5 | expect(response).to be_successful 6 | 7 | expect(json_body.size).to eq(100) 8 | expect(json_body.first.keys).to eq(['userId', 'id', 'title', 'body']) 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 16 | RSpec.configure do |config| 17 | # rspec-expectations config goes here. You can use an alternate 18 | # assertion/expectation library such as wrong or the stdlib/minitest 19 | # assertions if you prefer. 20 | config.expect_with :rspec do |expectations| 21 | # This option will default to `true` in RSpec 4. It makes the `description` 22 | # and `failure_message` of custom matchers include text for helper methods 23 | # defined using `chain`, e.g.: 24 | # be_bigger_than(2).and_smaller_than(4).description 25 | # # => "be bigger than 2 and smaller than 4" 26 | # ...rather than: 27 | # # => "be bigger than 2" 28 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 29 | end 30 | 31 | # rspec-mocks config goes here. You can use an alternate test double 32 | # library (such as bogus or mocha) by changing the `mock_with` option here. 33 | config.mock_with :rspec do |mocks| 34 | # Prevents you from mocking or stubbing a method that does not exist on 35 | # a real object. This is generally recommended, and will default to 36 | # `true` in RSpec 4. 37 | mocks.verify_partial_doubles = true 38 | end 39 | 40 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 41 | # have no way to turn it off -- the option exists only for backwards 42 | # compatibility in RSpec 3). It causes shared context metadata to be 43 | # inherited by the metadata hash of host groups and examples, rather than 44 | # triggering implicit auto-inclusion in groups with matching metadata. 45 | config.shared_context_metadata_behavior = :apply_to_host_groups 46 | 47 | # The settings below are suggested to provide a good initial experience 48 | # with RSpec, but feel free to customize to your heart's content. 49 | =begin 50 | # This allows you to limit a spec run to individual examples or groups 51 | # you care about by tagging them with `:focus` metadata. When nothing 52 | # is tagged with `:focus`, all examples get run. RSpec also provides 53 | # aliases for `it`, `describe`, and `context` that include `:focus` 54 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 55 | config.filter_run_when_matching :focus 56 | 57 | # Allows RSpec to persist some state between runs in order to support 58 | # the `--only-failures` and `--next-failure` CLI options. We recommend 59 | # you configure your source control system to ignore this file. 60 | config.example_status_persistence_file_path = "spec/examples.txt" 61 | 62 | # Limits the available syntax to the non-monkey patched syntax that is 63 | # recommended. For more details, see: 64 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 65 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 66 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 67 | config.disable_monkey_patching! 68 | 69 | # Many RSpec users commonly either run the entire suite or an individual 70 | # file, and it's useful to allow more verbose output when running an 71 | # individual spec file. 72 | if config.files_to_run.one? 73 | # Use the documentation formatter for detailed output, 74 | # unless a formatter has already been configured 75 | # (e.g. via a command-line flag). 76 | config.default_formatter = "doc" 77 | end 78 | 79 | # Print the 10 slowest examples and example groups at the 80 | # end of the spec run, to help surface which specs are running 81 | # particularly slow. 82 | config.profile_examples = 10 83 | 84 | # Run specs in random order to surface order dependencies. If you find an 85 | # order dependency and want to debug it, you can fix the order by providing 86 | # the seed, which is printed after each run. 87 | # --seed 1234 88 | config.order = :random 89 | 90 | # Seed global randomization in this process using the `--seed` CLI option. 91 | # Setting this allows you to use `--seed` to deterministically reproduce 92 | # test failures related to randomization by passing the same `--seed` value 93 | # as the one that triggered the failure. 94 | Kernel.srand config.seed 95 | =end 96 | end 97 | -------------------------------------------------------------------------------- /spec/support/api_helpers.rb: -------------------------------------------------------------------------------- 1 | module ApiHelpers 2 | def json_body 3 | JSON.parse(response.body) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/storage/.keep -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | purge: ["./app/**/*.vue", "./app/**/*.html.erb"], 3 | theme: {}, 4 | variants: {}, 5 | plugins: [], 6 | }; 7 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/tmp/.keep -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": false, 4 | "emitDecoratorMetadata": true, 5 | "experimentalDecorators": true, 6 | "lib": [ 7 | "es6", 8 | "dom" 9 | ], 10 | "module": "es6", 11 | "moduleResolution": "node", 12 | "baseUrl": ".", 13 | "paths": { 14 | "*": [ 15 | "node_modules/*", 16 | "app/javascript/*" 17 | ] 18 | }, 19 | "sourceMap": true, 20 | "target": "es5", 21 | "noEmit": true 22 | }, 23 | "exclude": [ 24 | "**/*.spec.ts", 25 | "node_modules", 26 | "vendor", 27 | "public" 28 | ], 29 | "compileOnSave": false 30 | } 31 | -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottrobertson/rails-vue-template/cc1b62f706c5ab536ed8f555b0a0da04e4a30c72/vendor/.keep --------------------------------------------------------------------------------