diff --git a/.gitignore b/.gitignore
index 7b2093c40..500ba0bba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@
.byebug_history
.vagrant*/
.env
+/storage/*
# never remove!
config/master.key
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index 3fed47413..c23a69fb0 100644
--- a/Gemfile
+++ b/Gemfile
@@ -15,6 +15,9 @@ gem 'sidekiq'
# active-record
gem 'ancestry'
+# active-storage
+gem 'aws-sdk-s3', require: false
+
# authentication
gem 'devise'
diff --git a/Gemfile.lock b/Gemfile.lock
index 3fe5615da..99d716950 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -53,6 +53,21 @@ GEM
io-like (~> 0.3.0)
arel (9.0.0)
ast (2.4.0)
+ aws-eventstream (1.0.1)
+ aws-partitions (1.97.0)
+ aws-sdk-core (3.24.0)
+ aws-eventstream (~> 1.0)
+ aws-partitions (~> 1.0)
+ aws-sigv4 (~> 1.0)
+ jmespath (~> 1.0)
+ aws-sdk-kms (1.7.0)
+ aws-sdk-core (~> 3)
+ aws-sigv4 (~> 1.0)
+ aws-sdk-s3 (1.17.0)
+ aws-sdk-core (~> 3, >= 3.21.2)
+ aws-sdk-kms (~> 1)
+ aws-sigv4 (~> 1.0)
+ aws-sigv4 (1.0.3)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
@@ -142,6 +157,7 @@ GEM
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
+ jmespath (1.4.0)
json (2.1.0)
kwalify (0.7.2)
launchy (2.4.3)
@@ -337,6 +353,7 @@ PLATFORMS
DEPENDENCIES
ancestry
+ aws-sdk-s3
bcrypt (~> 3.1.7)
bootsnap (>= 1.1.0)
brakeman
diff --git a/app/views/layouts/shared/_footer.html.erb b/app/views/layouts/shared/_footer.html.erb
index f13ea1ff4..65f3036ac 100644
--- a/app/views/layouts/shared/_footer.html.erb
+++ b/app/views/layouts/shared/_footer.html.erb
@@ -8,7 +8,9 @@
-
Nokul
+ <%= link_to 'https://github.com/omu/nokul' do %>
+ Nokul <%= Nokul::VERSION %>
+ <% end %>
© 2018 BAUM
diff --git a/config/environments/production.rb b/config/environments/production.rb
index f81d42569..dc06f8a5f 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -41,7 +41,7 @@
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options)
- config.active_storage.service = :local
+ config.active_storage.service = :minio
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
diff --git a/config/initializers/git_version.rb b/config/initializers/git_version.rb
new file mode 100644
index 000000000..7c3c9baca
--- /dev/null
+++ b/config/initializers/git_version.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+module Nokul
+ VERSION = `git describe --tags --abbrev=0`.chomp
+end
diff --git a/config/storage.yml b/config/storage.yml
index d32f76e8f..c3439ed79 100644
--- a/config/storage.yml
+++ b/config/storage.yml
@@ -1,24 +1,25 @@
test:
service: Disk
- root: <%= Rails.root.join("tmp/storage") %>
+ root: <%= Rails.root.join('tmp/storage') %>
local:
service: Disk
- root: <%= Rails.root.join("storage") %>
+ root: <%= Rails.root.join('storage') %>
-# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
-# amazon:
-# service: S3
-# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
-# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
-# region: us-east-1
-# bucket: your_own_bucket
+minio:
+ service: S3
+ access_key_id: <%= Rails.application.credentials.minio[:access_key] %>
+ secret_access_key: <%= Rails.application.credentials.minio[:secret_key] %>
+ region: us-east-1 # required for aws GEMs, can not be nil
+ bucket: nokul
+ endpoint: https://s3.omu.sh
+ force_path_style: true # use https://domain.com/bucket, instead of bucket.domain.com
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
-# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
+# credentials: <%= Rails.root.join('path/to/gcs.keyfile') %>
# bucket: your_own_bucket
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
diff --git a/db/migrate/20180807230631_create_active_storage_tables.active_storage.rb b/db/migrate/20180807230631_create_active_storage_tables.active_storage.rb
new file mode 100644
index 000000000..360e0d1b7
--- /dev/null
+++ b/db/migrate/20180807230631_create_active_storage_tables.active_storage.rb
@@ -0,0 +1,26 @@
+# This migration comes from active_storage (originally 20170806125915)
+class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
+ def change
+ create_table :active_storage_blobs do |t|
+ t.string :key, null: false
+ t.string :filename, null: false
+ t.string :content_type
+ t.text :metadata
+ t.bigint :byte_size, null: false
+ t.string :checksum, null: false
+ t.datetime :created_at, null: false
+
+ t.index [ :key ], unique: true
+ end
+
+ create_table :active_storage_attachments do |t|
+ t.string :name, null: false
+ t.references :record, null: false, polymorphic: true, index: false
+ t.references :blob, null: false
+
+ t.datetime :created_at, null: false
+
+ t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index a1ea2ffa9..07b75c1a6 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2018_08_03_203638) do
+ActiveRecord::Schema.define(version: 2018_08_07_230631) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -35,6 +35,27 @@
t.datetime "updated_at", null: false
end
+ create_table "active_storage_attachments", force: :cascade do |t|
+ t.string "name", null: false
+ t.string "record_type", null: false
+ t.bigint "record_id", null: false
+ t.bigint "blob_id", null: false
+ t.datetime "created_at", null: false
+ t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
+ t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
+ end
+
+ create_table "active_storage_blobs", force: :cascade do |t|
+ t.string "key", null: false
+ t.string "filename", null: false
+ t.string "content_type"
+ t.text "metadata"
+ t.bigint "byte_size", null: false
+ t.string "checksum", null: false
+ t.datetime "created_at", null: false
+ t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
+ end
+
create_table "addresses", force: :cascade do |t|
t.integer "type", default: 4, null: false
t.string "phone_number", default: "", null: false