From 7deadfebdd44ca6550c8ebd1dcb1ab7fe5130d4e Mon Sep 17 00:00:00 2001 From: chenjing Date: Mon, 8 Jul 2019 15:04:00 +0800 Subject: [PATCH] redis --- Gemfile | 4 ++-- Gemfile.lock | 21 +++++++++++++++++++-- app/assets/javascripts/invote.coffee | 3 +++ app/assets/stylesheets/invote.scss | 3 +++ app/controllers/invote_controller.rb | 10 ++++++++++ app/helpers/invote_helper.rb | 2 ++ app/views/invote/show.erb | 1 + config/environments/production.rb | 2 +- config/routes.rb | 3 +++ docker-compose.yml | 8 +++----- test/controllers/invote_controller_test.rb | 7 +++++++ 11 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 app/assets/javascripts/invote.coffee create mode 100644 app/assets/stylesheets/invote.scss create mode 100644 app/controllers/invote_controller.rb create mode 100644 app/helpers/invote_helper.rb create mode 100644 app/views/invote/show.erb create mode 100644 test/controllers/invote_controller_test.rb diff --git a/Gemfile b/Gemfile index b53fea0..15a1eaf 100644 --- a/Gemfile +++ b/Gemfile @@ -6,9 +6,9 @@ ruby '2.6.2' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.3' # Use sqlite3 as the database for Active Record -gem 'sqlite3' -# Use Puma as the app server gem 'puma', '~> 3.11' +gem 'redis', '~> 4.0' +gem 'redis-rails', '~> 5' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets diff --git a/Gemfile.lock b/Gemfile.lock index ee386ae..ba568d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -143,6 +143,23 @@ GEM rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) + redis (4.1.1) + redis-actionpack (5.0.2) + actionpack (>= 4.0, < 6) + redis-rack (>= 1, < 3) + redis-store (>= 1.1.0, < 2) + redis-activesupport (5.0.7) + activesupport (>= 3, < 6) + redis-store (>= 1.3, < 2) + redis-rack (2.0.5) + rack (>= 1.5, < 3) + redis-store (>= 1.2, < 2) + redis-rails (5.0.2) + redis-actionpack (>= 5.0, < 6) + redis-activesupport (>= 5.0, < 6) + redis-store (>= 1.2, < 2) + redis-store (1.6.0) + redis (>= 2.2, < 5) regexp_parser (1.5.1) ruby_dep (1.5.0) rubyzip (1.2.3) @@ -171,7 +188,6 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.4.1) thor (0.20.3) thread_safe (0.3.6) tilt (2.0.9) @@ -207,11 +223,12 @@ DEPENDENCIES pry-rails puma (~> 3.11) rails (~> 5.2.3) + redis (~> 4.0) + redis-rails (~> 5) sass-rails (~> 5.0) selenium-webdriver spring spring-watcher-listen (~> 2.0.0) - sqlite3 turbolinks (~> 5) tzinfo-data uglifier (>= 1.3.0) diff --git a/app/assets/javascripts/invote.coffee b/app/assets/javascripts/invote.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/invote.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/invote.scss b/app/assets/stylesheets/invote.scss new file mode 100644 index 0000000..7fbd843 --- /dev/null +++ b/app/assets/stylesheets/invote.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the invote controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/invote_controller.rb b/app/controllers/invote_controller.rb new file mode 100644 index 0000000..8f5ae3a --- /dev/null +++ b/app/controllers/invote_controller.rb @@ -0,0 +1,10 @@ +class InvoteController < ApplicationController + + def show + + end + + def create + + end +end diff --git a/app/helpers/invote_helper.rb b/app/helpers/invote_helper.rb new file mode 100644 index 0000000..5b20f12 --- /dev/null +++ b/app/helpers/invote_helper.rb @@ -0,0 +1,2 @@ +module InvoteHelper +end diff --git a/app/views/invote/show.erb b/app/views/invote/show.erb new file mode 100644 index 0000000..d72af31 --- /dev/null +++ b/app/views/invote/show.erb @@ -0,0 +1 @@ +asd diff --git a/config/environments/production.rb b/config/environments/production.rb index 1a71527..9d5c50a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -17,7 +17,7 @@ Rails.application.configure do # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true - + config.cache_store = :redis_store, ENV["REDIS_URL"] # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? diff --git a/config/routes.rb b/config/routes.rb index 787824f..ec73685 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,6 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + resource :invote + + root "invote#show" end diff --git a/docker-compose.yml b/docker-compose.yml index 52c1db1..905c550 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,11 +7,9 @@ services: context: . dockerfile: ./docker/app/DockerFile depends_on: - - db - db: - image: sqlite3 - volumes: - - sqlite_data:/var/lib/sqlite/data + - redis + redis: + image: redis:alpine web: build: context: . diff --git a/test/controllers/invote_controller_test.rb b/test/controllers/invote_controller_test.rb new file mode 100644 index 0000000..104bea0 --- /dev/null +++ b/test/controllers/invote_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class InvoteControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end