├── .cloud └── docker │ ├── Dockerfile │ └── docker-entrypoint.sh ├── .gitignore ├── .ruby-version ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── Rakefile ├── app ├── controllers │ ├── api │ │ └── v1 │ │ │ ├── base_controller.rb │ │ │ └── posts_controller.rb │ └── application_controller.rb ├── models │ ├── application_record.rb │ └── post.rb └── serializers │ ├── error_serializer.rb │ └── post_serializer.rb ├── bin ├── bundle ├── rails ├── rake └── setup ├── config.ru ├── config ├── application.rb ├── boot.rb ├── credentials.yml.enc ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── application_controller_renderer.rb │ ├── backtrace_silencers.rb │ ├── content_security_policy.rb │ ├── cookies_serializer.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── master.key ├── puma.rb └── routes.rb ├── db ├── migrate │ └── 20191014160047_create_posts.rb ├── schema.rb └── seeds.rb ├── frontend ├── .browserslistrc ├── .eslintrc.js ├── .gitignore ├── babel.config.js ├── package.json ├── postcss.config.js ├── public │ ├── favicon.ico │ └── index.html ├── src │ ├── App.vue │ ├── assets │ │ └── logo.png │ ├── components │ │ ├── Navbar.vue │ │ └── Post │ │ │ ├── Card.vue │ │ │ └── Form.vue │ ├── main.js │ ├── plugins │ │ ├── bootstrap-vue.js │ │ └── vue-meta.js │ ├── router.js │ ├── store │ │ ├── index.js │ │ └── models │ │ │ └── Post.js │ ├── utils │ │ ├── Errors.js │ │ └── Form.js │ └── views │ │ └── Posts │ │ ├── Edit.vue │ │ ├── Index.vue │ │ └── New.vue ├── vue.config.js └── yarn.lock ├── log └── .keep └── tmp └── .keep /.cloud/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM guillaumebriday/ruby-node:2.6.4-slim 2 | 3 | LABEL maintainer="guillaumebriday@gmail.com" 4 | LABEL traefik.enable="true" 5 | LABEL traefik.port="3000" 6 | 7 | # Set our working directory. 8 | WORKDIR /var/www 9 | 10 | # Setting env up 11 | ENV RAILS_ENV="production" \ 12 | RACK_ENV="production" \ 13 | RAILS_SERVE_STATIC_FILES="true" 14 | 15 | # Installing dependencies 16 | RUN apt-get update && \ 17 | mkdir -p /usr/share/man/man1 && \ 18 | mkdir -p /usr/share/man/man7 && \ 19 | apt-get install -y --no-install-recommends \ 20 | build-essential \ 21 | apt-transport-https \ 22 | sqlite3 \ 23 | libsqlite3-dev \ 24 | curl \ 25 | bash 26 | 27 | # Clear cache 28 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 29 | 30 | # Copy the config in the container 31 | COPY . . 32 | COPY .cloud/docker/docker-entrypoint.sh /usr/local/bin/ 33 | RUN chmod +x /usr/local/bin/docker-entrypoint.sh 34 | 35 | RUN gem install bundler --no-document 36 | RUN bundle install -j $(nproc) --without development test 37 | RUN cd frontend && yarn build 38 | 39 | # Expose HTTP port 40 | EXPOSE 3000 41 | 42 | # Execute our entry script. 43 | CMD ["docker-entrypoint.sh"] 44 | -------------------------------------------------------------------------------- /.cloud/docker/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | until bundle exec rake db:version; do 4 | >&2 echo "Sqlite is unavailable - sleeping" 5 | sleep 1 6 | done 7 | 8 | bundle exec rake db:migrate 9 | bundle exec rake db:seed 10 | 11 | bundle exec puma -C config/puma.rb 12 | -------------------------------------------------------------------------------- /.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 | 17 | /public 18 | .byebug_history 19 | 20 | app/views/application.html.erb 21 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.6.4 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby '2.6.4' 5 | 6 | gem 'rails', '~> 6.0.0' 7 | gem 'sqlite3' 8 | gem 'puma', '~> 3.11' 9 | gem 'fast_jsonapi' 10 | 11 | group :development, :test do 12 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 13 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 14 | end 15 | 16 | group :development do 17 | # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 18 | gem 'web-console', '>= 3.3.0' 19 | gem 'listen', '>= 3.0.5', '< 3.2' 20 | end 21 | 22 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 23 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 24 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (6.0.0) 5 | actionpack (= 6.0.0) 6 | nio4r (~> 2.0) 7 | websocket-driver (>= 0.6.1) 8 | actionmailbox (6.0.0) 9 | actionpack (= 6.0.0) 10 | activejob (= 6.0.0) 11 | activerecord (= 6.0.0) 12 | activestorage (= 6.0.0) 13 | activesupport (= 6.0.0) 14 | mail (>= 2.7.1) 15 | actionmailer (6.0.0) 16 | actionpack (= 6.0.0) 17 | actionview (= 6.0.0) 18 | activejob (= 6.0.0) 19 | mail (~> 2.5, >= 2.5.4) 20 | rails-dom-testing (~> 2.0) 21 | actionpack (6.0.0) 22 | actionview (= 6.0.0) 23 | activesupport (= 6.0.0) 24 | rack (~> 2.0) 25 | rack-test (>= 0.6.3) 26 | rails-dom-testing (~> 2.0) 27 | rails-html-sanitizer (~> 1.0, >= 1.2.0) 28 | actiontext (6.0.0) 29 | actionpack (= 6.0.0) 30 | activerecord (= 6.0.0) 31 | activestorage (= 6.0.0) 32 | activesupport (= 6.0.0) 33 | nokogiri (>= 1.8.5) 34 | actionview (6.0.0) 35 | activesupport (= 6.0.0) 36 | builder (~> 3.1) 37 | erubi (~> 1.4) 38 | rails-dom-testing (~> 2.0) 39 | rails-html-sanitizer (~> 1.1, >= 1.2.0) 40 | activejob (6.0.0) 41 | activesupport (= 6.0.0) 42 | globalid (>= 0.3.6) 43 | activemodel (6.0.0) 44 | activesupport (= 6.0.0) 45 | activerecord (6.0.0) 46 | activemodel (= 6.0.0) 47 | activesupport (= 6.0.0) 48 | activestorage (6.0.0) 49 | actionpack (= 6.0.0) 50 | activejob (= 6.0.0) 51 | activerecord (= 6.0.0) 52 | marcel (~> 0.3.1) 53 | activesupport (6.0.0) 54 | concurrent-ruby (~> 1.0, >= 1.0.2) 55 | i18n (>= 0.7, < 2) 56 | minitest (~> 5.1) 57 | tzinfo (~> 1.1) 58 | zeitwerk (~> 2.1, >= 2.1.8) 59 | bindex (0.8.1) 60 | builder (3.2.3) 61 | byebug (11.0.1) 62 | concurrent-ruby (1.1.5) 63 | crass (1.0.4) 64 | erubi (1.9.0) 65 | fast_jsonapi (1.5) 66 | activesupport (>= 4.2) 67 | ffi (1.11.1) 68 | globalid (0.4.2) 69 | activesupport (>= 4.2.0) 70 | i18n (1.7.0) 71 | concurrent-ruby (~> 1.0) 72 | listen (3.1.5) 73 | rb-fsevent (~> 0.9, >= 0.9.4) 74 | rb-inotify (~> 0.9, >= 0.9.7) 75 | ruby_dep (~> 1.2) 76 | loofah (2.3.0) 77 | crass (~> 1.0.2) 78 | nokogiri (>= 1.5.9) 79 | mail (2.7.1) 80 | mini_mime (>= 0.1.1) 81 | marcel (0.3.3) 82 | mimemagic (~> 0.3.2) 83 | method_source (0.9.2) 84 | mimemagic (0.3.3) 85 | mini_mime (1.0.2) 86 | mini_portile2 (2.4.0) 87 | minitest (5.12.2) 88 | nio4r (2.5.2) 89 | nokogiri (1.10.4) 90 | mini_portile2 (~> 2.4.0) 91 | puma (3.12.1) 92 | rack (2.0.7) 93 | rack-test (1.1.0) 94 | rack (>= 1.0, < 3) 95 | rails (6.0.0) 96 | actioncable (= 6.0.0) 97 | actionmailbox (= 6.0.0) 98 | actionmailer (= 6.0.0) 99 | actionpack (= 6.0.0) 100 | actiontext (= 6.0.0) 101 | actionview (= 6.0.0) 102 | activejob (= 6.0.0) 103 | activemodel (= 6.0.0) 104 | activerecord (= 6.0.0) 105 | activestorage (= 6.0.0) 106 | activesupport (= 6.0.0) 107 | bundler (>= 1.3.0) 108 | railties (= 6.0.0) 109 | sprockets-rails (>= 2.0.0) 110 | rails-dom-testing (2.0.3) 111 | activesupport (>= 4.2.0) 112 | nokogiri (>= 1.6) 113 | rails-html-sanitizer (1.3.0) 114 | loofah (~> 2.3) 115 | railties (6.0.0) 116 | actionpack (= 6.0.0) 117 | activesupport (= 6.0.0) 118 | method_source 119 | rake (>= 0.8.7) 120 | thor (>= 0.20.3, < 2.0) 121 | rake (13.0.0) 122 | rb-fsevent (0.10.3) 123 | rb-inotify (0.10.0) 124 | ffi (~> 1.0) 125 | ruby_dep (1.5.0) 126 | sprockets (4.0.0) 127 | concurrent-ruby (~> 1.0) 128 | rack (> 1, < 3) 129 | sprockets-rails (3.2.1) 130 | actionpack (>= 4.0) 131 | activesupport (>= 4.0) 132 | sprockets (>= 3.0.0) 133 | sqlite3 (1.4.1) 134 | thor (0.20.3) 135 | thread_safe (0.3.6) 136 | tzinfo (1.2.5) 137 | thread_safe (~> 0.1) 138 | web-console (4.0.1) 139 | actionview (>= 6.0.0) 140 | activemodel (>= 6.0.0) 141 | bindex (>= 0.4.0) 142 | railties (>= 6.0.0) 143 | websocket-driver (0.7.1) 144 | websocket-extensions (>= 0.1.0) 145 | websocket-extensions (0.1.4) 146 | zeitwerk (2.2.0) 147 | 148 | PLATFORMS 149 | ruby 150 | 151 | DEPENDENCIES 152 | byebug 153 | fast_jsonapi 154 | listen (>= 3.0.5, < 3.2) 155 | puma (~> 3.11) 156 | rails (~> 6.0.0) 157 | sqlite3 158 | tzinfo-data 159 | web-console (>= 3.3.0) 160 | 161 | RUBY VERSION 162 | ruby 2.6.4p104 163 | 164 | BUNDLED WITH 165 | 2.0.2 166 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Guillaume Briday 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rails and Vue CLI 2 | 3 | [](https://hub.docker.com/r/guillaumebriday/rails-vue-cli) 4 | [](https://github.com/guillaumebriday/rails-vue-cli) 5 | 6 | - [Concept Overview](#concept-overview) 7 | - [Why?](#why) 8 | - [How it works](#how-it-works) 9 | - [Getting started](#getting-started) 10 | - [Install](#install) 11 | - [Development](#development) 12 | - [Deploy in production](#deploy-in-production) 13 | - [Contributing](#contributing) 14 | - [Credits](#credits) 15 | - [License](#license) 16 | 17 | ## Concept Overview 18 | 19 | This project shows how to build an application with both [Rails](https://rubyonrails.org/) and [Vue CLI](https://cli.vuejs.org/) in the same repo. 20 | 21 | It **does not** use the Rails gem [Webpacker](https://github.com/rails/webpacker) to manage JavaScript and CSS. It's fully delegated to Vue CLI. 22 | 23 | ## Why? 24 | 25 | Because sometime you want to use the power of Vue CLI and work with the "classic" Vue ecosystem. 26 | 27 | ## How it works 28 | 29 | Rails is only responsible for two things. 30 | 31 | 1. Serve the first HTML page built with Vue CLI. 32 | 2. Expose an API. 33 | 34 | In the Rails routes, you can see: 35 | 36 | ```ruby 37 | get '*path', to: 'application#index', format: false 38 | ``` 39 | 40 | And the Application controller: 41 | 42 | ```ruby 43 | class ApplicationController < ActionController::Base 44 | def index 45 | render template: 'application' 46 | end 47 | end 48 | ``` 49 | 50 | It means that Rails will dispatch any requests to the `app/views/application.html.erb` view. 51 | The Vue router is responsible to handle those requests with the correct components after the first load of the page. 52 | 53 | For every API requests, we use the `:api` namespace to serve JSON in the same application that Vue CLI can use. 54 | 55 | In the `frontend/vue.config.js`: 56 | 57 | ```js 58 | module.exports = { 59 | // proxy API requests to Rails during development 60 | devServer: { 61 | proxy: "http://localhost:3000" 62 | }, 63 | 64 | // output built static files to Rails's public dir. 65 | // note the "build" script in package.json needs to be modified as well. 66 | outputDir: "../public", 67 | 68 | // modify the location of the generated HTML file. 69 | // make sure to do this only in production. 70 | indexPath: 71 | process.env.NODE_ENV === "production" 72 | ? "../app/views/application.html.erb" 73 | : "index.html" 74 | }; 75 | ``` 76 | 77 | We build the application in the Rails's public dir so it can be served by your Web server on production. 78 | 79 | The `indexPath` is responsible to generate the `app/views/application.html.erb` that the `ApplicationController` will use. 80 | 81 | In development, we now have two endpoints, `localhost:3000` for the api and `localhost:8080` for the Vue App. 82 | 83 | In production, it works exactly the same way as if you run `rails assets:precompile` but CSS and JS are precompiled by Vue CLI instead. 84 | 85 | ## Getting started 86 | 87 | ### Install 88 | 89 | Development environment requirements : 90 | - [Ruby](https://www.ruby-lang.org/en/) 91 | - [Node](https://nodejs.org/en/) 92 | 93 | ```bash 94 | $ git clone https://github.com/guillaumebriday/rails-vue-cli.git 95 | $ cd rails-vue-cli 96 | ``` 97 | 98 | To run the backend 99 | ```bash 100 | $ bundle 101 | $ bin/setup 102 | $ rm config/credentials.yml.enc && bundle exec rails credentials:edit 103 | $ bundle exec rails s 104 | ``` 105 | 106 | To run the Frontend: 107 | ```bash 108 | $ cd frontend 109 | $ yarn 110 | $ yarn serve 111 | ``` 112 | 113 | Open [http://localhost:8080](http://localhost:8080) in your browser. 114 | 115 | ### Development 116 | 117 | Lint and fix Vue files: 118 | ```bash 119 | $ cd frontend 120 | $ yarn lint --fix 121 | ``` 122 | 123 | Build the image locally : 124 | ``` 125 | $ docker build -f .cloud/docker/Dockerfile -t rails-vue-cli . 126 | ``` 127 | 128 | ## Deploy in production 129 | 130 | You need to build the frontend like you used to do with [Webpacker](https://github.com/rails/webpacker): 131 | 132 | ```bash 133 | $ cd frontend 134 | $ yarn build 135 | ``` 136 | 137 | ## Contributing 138 | 139 | Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome. 140 | 141 | ## Credits 142 | 143 | Inspired by: 144 | 145 | + [https://github.com/yyx990803/laravel-vue-cli-3](https://github.com/yyx990803/laravel-vue-cli-3) 146 | 147 | ## License 148 | 149 | This project is released under the [MIT](http://opensource.org/licenses/MIT) license. 150 | -------------------------------------------------------------------------------- /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/controllers/api/v1/base_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Api::V1::BaseController < ActionController::API 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/api/v1/posts_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Api::V1::PostsController < Api::V1::BaseController 4 | before_action :set_post, only: %i[show update destroy] 5 | 6 | def index 7 | posts = Post.all 8 | 9 | render json: PostSerializer.new(posts) 10 | end 11 | 12 | def show 13 | render json: PostSerializer.new(@post) 14 | end 15 | 16 | def create 17 | post = Post.new(post_params) 18 | 19 | if post.save 20 | render json: PostSerializer.new(post), status: :created, location: [:api, :v1, post] 21 | else 22 | render json: ErrorSerializer.new(post), status: :unprocessable_entity 23 | end 24 | end 25 | 26 | def update 27 | @post.attributes = post_params 28 | 29 | if @post.save 30 | render json: PostSerializer.new(@post) 31 | else 32 | render json: ErrorSerializer.new(@post), status: :unprocessable_entity 33 | end 34 | end 35 | 36 | def destroy 37 | @post.destroy 38 | 39 | head :no_content 40 | end 41 | 42 | private 43 | 44 | def set_post 45 | @post = Post.find(params[:id]) 46 | end 47 | 48 | def post_params 49 | params 50 | .fetch(:post, {}) 51 | .permit( 52 | :title, 53 | :content 54 | ) 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ApplicationController < ActionController::Base 4 | def index 5 | render template: 'application' 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ApplicationRecord < ActiveRecord::Base 4 | self.abstract_class = true 5 | end 6 | -------------------------------------------------------------------------------- /app/models/post.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Post < ApplicationRecord 4 | validates :title, 5 | :content, 6 | presence: true 7 | end 8 | -------------------------------------------------------------------------------- /app/serializers/error_serializer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module ErrorSerializer 4 | def self.new(object) 5 | errors = {} 6 | 7 | object.errors.messages.each do |attribute, _errors| 8 | errors[attribute] = object.errors.full_messages_for(attribute) 9 | end 10 | 11 | { errors: errors } 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /app/serializers/post_serializer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class PostSerializer 4 | include FastJsonapi::ObjectSerializer 5 | 6 | attributes :title, :content, :created_at, :updated_at 7 | end 8 | -------------------------------------------------------------------------------- /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 | APP_PATH = File.expand_path('../config/application', __dir__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path('..', __dir__) 6 | 7 | def system!(*args) 8 | system(*args) || abort("\n== Command #{args} failed ==") 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to setup or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at anytime and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # puts "\n== Copying sample files ==" 21 | # unless File.exist?('config/database.yml') 22 | # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' 23 | # end 24 | 25 | puts "\n== Preparing database ==" 26 | system! 'bin/rails db:prepare' 27 | 28 | puts "\n== Removing old logs and tempfiles ==" 29 | system! 'bin/rails log:clear tmp:clear' 30 | 31 | puts "\n== Restarting application server ==" 32 | system! 'bin/rails restart' 33 | end 34 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require "rails" 4 | # Pick the frameworks you want: 5 | require "active_model/railtie" 6 | require "active_job/railtie" 7 | require "active_record/railtie" 8 | # require "active_storage/engine" 9 | require "action_controller/railtie" 10 | # require "action_mailer/railtie" 11 | # require "action_mailbox/engine" 12 | # require "action_text/engine" 13 | require "action_view/railtie" 14 | # require "action_cable/engine" 15 | # require "sprockets/railtie" 16 | require "rails/test_unit/railtie" 17 | 18 | # Require the gems listed in Gemfile, including any gems 19 | # you've limited to :test, :development, or :production. 20 | Bundler.require(*Rails.groups) 21 | 22 | module RailsVueCli 23 | class Application < Rails::Application 24 | # Initialize configuration defaults for originally generated Rails version. 25 | config.load_defaults 6.0 26 | 27 | # Settings in config/environments/* take precedence over those specified here. 28 | # Application configuration can go into files in config/initializers 29 | # -- all .rb files in that directory are automatically loaded after loading 30 | # the framework and any gems in your application. 31 | 32 | # Don't generate system test files. 33 | config.generators.system_tests = nil 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | /M85++JpC88E7mivG1xsAEX4e6eNj1UYIt1viPIFp3BD0jgXzGrIPkNV+DFGy9Asxp9K9lE75sh4AWRxr1n8gCW5WJj4xrUzUfXRwePt4X3VaUizR4kiiofp82C+x16dPkhIOOnei0V/Y+TlUy3mnyisny6+d9/JDIF/ya9k4uTvWk3MHJoPW5Za2geFjwBf9aJ+fQtCiAsVBVZ59kHz2qp83SON5zMOKS7wZ+5Qz3detBhCaN3kd//Bc0lJrcNV2hVMHvK/k3z6vQ68jr62HVr/pwORolSyLRxzILG9wKAFtcANBPmffssdRjV9Hb+vkHHwdC080pNdlFAJXxtn15WKKtEHHQej9ZMCfpWkz/trK0BpdfD8wJxT/NCAwJVeC63x0VUeBe5wfYFz6hTZWYgj1uT66a7KVkQJ--WCaSl2ujxBm1uvHm--zbUTfIBoTXmuPVsDq+s7TQ== -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite. Versions 3.8.0 and up are supported. 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | # Run rails dev:cache to toggle caching. 17 | if Rails.root.join('tmp', 'caching-dev.txt').exist? 18 | config.action_controller.perform_caching = true 19 | config.action_controller.enable_fragment_cache_logging = true 20 | 21 | config.cache_store = :memory_store 22 | config.public_file_server.headers = { 23 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 24 | } 25 | else 26 | config.action_controller.perform_caching = false 27 | 28 | config.cache_store = :null_store 29 | end 30 | 31 | # Print deprecation notices to the Rails logger. 32 | config.active_support.deprecation = :log 33 | 34 | # Raise an error on page load if there are pending migrations. 35 | config.active_record.migration_error = :page_load 36 | 37 | # Highlight code that triggered database queries in logs. 38 | config.active_record.verbose_query_logs = true 39 | 40 | 41 | # Raises error for missing translations. 42 | # config.action_view.raise_on_missing_translations = true 43 | 44 | # Use an evented file watcher to asynchronously detect changes in source code, 45 | # routes, locales, etc. This feature depends on the listen gem. 46 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 47 | end 48 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 18 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 19 | # config.require_master_key = true 20 | 21 | # Disable serving static files from the `/public` folder by default since 22 | # Apache or NGINX already handles this. 23 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 24 | 25 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 26 | # config.action_controller.asset_host = 'http://assets.example.com' 27 | 28 | # Specifies the header that your server uses for sending files. 29 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 30 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 31 | 32 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 33 | # config.force_ssl = true 34 | 35 | # Use the lowest log level to ensure availability of diagnostic information 36 | # when problems arise. 37 | config.log_level = :debug 38 | 39 | # Prepend all log lines with the following tags. 40 | config.log_tags = [ :request_id ] 41 | 42 | # Use a different cache store in production. 43 | # config.cache_store = :mem_cache_store 44 | 45 | # Use a real queuing backend for Active Job (and separate queues per environment). 46 | # config.active_job.queue_adapter = :resque 47 | # config.active_job.queue_name_prefix = "rails_vue_cli_production" 48 | 49 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 50 | # the I18n.default_locale when a translation cannot be found). 51 | config.i18n.fallbacks = true 52 | 53 | # Send deprecation notices to registered listeners. 54 | config.active_support.deprecation = :notify 55 | 56 | # Use default logging formatter so that PID and timestamp are not suppressed. 57 | config.log_formatter = ::Logger::Formatter.new 58 | 59 | # Use a different logger for distributed setups. 60 | # require 'syslog/logger' 61 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 62 | 63 | if ENV["RAILS_LOG_TO_STDOUT"].present? 64 | logger = ActiveSupport::Logger.new(STDOUT) 65 | logger.formatter = config.log_formatter 66 | config.logger = ActiveSupport::TaggedLogging.new(logger) 67 | end 68 | 69 | # Do not dump schema after migrations. 70 | config.active_record.dump_schema_after_migration = false 71 | 72 | # Inserts middleware to perform automatic connection switching. 73 | # The `database_selector` hash is used to pass options to the DatabaseSelector 74 | # middleware. The `delay` is used to determine how long to wait after a write 75 | # to send a subsequent read to the primary. 76 | # 77 | # The `database_resolver` class is used by the middleware to determine which 78 | # database is appropriate to use based on the time delay. 79 | # 80 | # The `database_resolver_context` class is used by the middleware to set 81 | # timestamps for the last write to the primary. The resolver uses the context 82 | # class timestamps to determine how long to wait before reading from the 83 | # replica. 84 | # 85 | # By default Rails will store a last write timestamp in the session. The 86 | # DatabaseSelector middleware is designed as such you can define your own 87 | # strategy for connection switching and pass that into the middleware through 88 | # these configuration options. 89 | # config.active_record.database_selector = { delay: 2.seconds } 90 | # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver 91 | # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session 92 | end 93 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | # The test environment is used exclusively to run your application's 2 | # test suite. You never need to work with it otherwise. Remember that 3 | # your test database is "scratch space" for the test suite and is wiped 4 | # and recreated between test runs. Don't rely on the data there! 5 | 6 | Rails.application.configure do 7 | # Settings specified here will take precedence over those in config/application.rb. 8 | 9 | config.cache_classes = true 10 | 11 | # Do not eager load code on boot. This avoids loading your whole application 12 | # just for the purpose of running a single test. If you are using a tool that 13 | # preloads Rails for running tests, you may have to set it to true. 14 | config.eager_load = false 15 | 16 | # Configure public file server for tests with Cache-Control for performance. 17 | config.public_file_server.enabled = true 18 | config.public_file_server.headers = { 19 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 20 | } 21 | 22 | # Show full error reports and disable caching. 23 | config.consider_all_requests_local = true 24 | config.action_controller.perform_caching = false 25 | config.cache_store = :null_store 26 | 27 | # Raise exceptions instead of rendering exception templates. 28 | config.action_dispatch.show_exceptions = false 29 | 30 | # Disable request forgery protection in test environment. 31 | config.action_controller.allow_forgery_protection = false 32 | 33 | # Print deprecation notices to the stderr. 34 | config.active_support.deprecation = :stderr 35 | 36 | # Raises error for missing translations. 37 | # config.action_view.raise_on_missing_translations = true 38 | end 39 | -------------------------------------------------------------------------------- /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/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy 4 | # For further information see the following documentation 5 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy 6 | 7 | # Rails.application.config.content_security_policy do |policy| 8 | # policy.default_src :self, :https 9 | # policy.font_src :self, :https, :data 10 | # policy.img_src :self, :https, :data 11 | # policy.object_src :none 12 | # policy.script_src :self, :https 13 | # policy.style_src :self, :https 14 | 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | 19 | # If you are using UJS then enable automatic nonce generation 20 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } 21 | 22 | # Set the nonce only to specific directives 23 | # Rails.application.config.content_security_policy_nonce_directives = %w(script-src) 24 | 25 | # Report CSP violations to a specified URI 26 | # For further information see the following documentation: 27 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only 28 | # Rails.application.config.content_security_policy_report_only = true 29 | -------------------------------------------------------------------------------- /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 += [:password] 5 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/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/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/master.key: -------------------------------------------------------------------------------- 1 | 5a3063155685b2e4fd435cb773e696f3 -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } 9 | threads min_threads_count, max_threads_count 10 | 11 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 12 | # 13 | port ENV.fetch("PORT") { 3000 } 14 | 15 | # Specifies the `environment` that Puma will run in. 16 | # 17 | environment ENV.fetch("RAILS_ENV") { "development" } 18 | 19 | # Specifies the `pidfile` that Puma will use. 20 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 21 | 22 | # Specifies the number of `workers` to boot in clustered mode. 23 | # Workers are forked web server processes. If using threads and workers together 24 | # the concurrency of the application would be max `threads` * `workers`. 25 | # Workers do not work on JRuby or Windows (both of which do not support 26 | # processes). 27 | # 28 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 29 | 30 | # Use the `preload_app!` method when specifying a `workers` number. 31 | # This directive tells Puma to first boot the application and load code 32 | # before forking the application. This takes advantage of Copy On Write 33 | # process behavior so workers use less memory. 34 | # 35 | # preload_app! 36 | 37 | # Allow puma to be restarted by `rails restart` command. 38 | plugin :tmp_restart 39 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | namespace :api, defaults: { format: :json } do 3 | namespace :v1 do 4 | resources :posts, except: [:new, :edit] 5 | end 6 | end 7 | 8 | root to: 'application#index' 9 | get '*path', to: 'application#index', format: false 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20191014160047_create_posts.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreatePosts < ActiveRecord::Migration[6.0] 4 | def change 5 | create_table :posts do |t| 6 | t.string :title 7 | t.text :content 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # This file is the source Rails uses to define your schema when running `rails 6 | # db:schema:load`. When creating a new database, `rails db:schema:load` tends to 7 | # be faster and is potentially less error prone than running all of your 8 | # migrations from scratch. Old migrations may fail to apply correctly if those 9 | # migrations use external dependencies or application code. 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 2019_10_14_160047) do 14 | 15 | create_table "posts", force: :cascade do |t| 16 | t.string "title" 17 | t.text "content" 18 | t.datetime "created_at", precision: 6, null: false 19 | t.datetime "updated_at", precision: 6, null: false 20 | end 21 | 22 | create_table "posts", force: :cascade do |t| 23 | t.string "title" 24 | t.text "content" 25 | t.datetime "created_at", precision: 6, null: false 26 | t.datetime "updated_at", precision: 6, null: false 27 | end 28 | 29 | end 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /frontend/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | -------------------------------------------------------------------------------- /frontend/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ["plugin:vue/essential", "@vue/prettier"], 7 | rules: { 8 | "no-console": process.env.NODE_ENV === "production" ? "error" : "off", 9 | "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" 10 | }, 11 | parserOptions: { 12 | parser: "babel-eslint" 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /frontend/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/cli-plugin-babel/preset"] 3 | }; 4 | -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "rm -rf ../public/{js,css,img} && vue-cli-service build --no-clean", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "@vuex-orm/core": "0.32.1", 12 | "@vuex-orm/plugin-axios": "^0.5.1", 13 | "add": "^2.0.6", 14 | "bootstrap-vue": "^2.0.0-rc.19", 15 | "core-js": "^3.1.2", 16 | "json-api-response-converter": "^1.3.0", 17 | "vue": "^2.6.10", 18 | "vue-meta": "^2.3.1", 19 | "vue-router": "^3.0.3", 20 | "vuex": "^3.1.1", 21 | "yarn": "^1.19.1" 22 | }, 23 | "devDependencies": { 24 | "@vue/cli-plugin-babel": "^4.0.0", 25 | "@vue/cli-plugin-eslint": "^4.0.1", 26 | "@vue/cli-service": "^4.0.0", 27 | "@vue/eslint-config-prettier": "^5.0.0", 28 | "babel-eslint": "^10.0.1", 29 | "bootstrap": "^4.3.1", 30 | "eslint": "^6.5.1", 31 | "eslint-plugin-prettier": "^3.1.0", 32 | "eslint-plugin-vue": "^5.0.0", 33 | "node-sass": "^4.12.0", 34 | "popper.js": "^1.16.0", 35 | "portal-vue": "^2.1.4", 36 | "prettier": "^1.18.2", 37 | "sass-loader": "^8.0.0", 38 | "vue-cli-plugin-bootstrap-vue": "^0.4.0", 39 | "vue-template-compiler": "^2.6.10" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /frontend/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | }; 6 | -------------------------------------------------------------------------------- /frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guillaumebriday/rails-vue-cli/0d43e5e99cade860250d44ee8b04a3a040d5a106/frontend/public/favicon.ico -------------------------------------------------------------------------------- /frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 |List of all posts.
5 |No posts.
19 |