Created
June 2, 2019 16:17
-
-
Save csexton/ab548efaea5ec8a824912096bb593ad7 to your computer and use it in GitHub Desktop.
Terrastories local dev mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/rails/Gemfile b/rails/Gemfile | |
index 0262b60..61d5bd8 100644 | |
--- a/rails/Gemfile | |
+++ b/rails/Gemfile | |
@@ -6,6 +6,7 @@ ruby '2.5.1' | |
gem 'rails', '~> 5.2.0' | |
# Use mysql as the database for Active Record | |
gem 'mysql2', '>= 0.4.4', '< 0.6.0' | |
+gem 'sqlite3' | |
# Use Puma as the app server | |
gem 'puma', '~> 3.11' | |
# Already has rgeo | |
diff --git a/rails/app/models/speaker.rb b/rails/app/models/speaker.rb | |
index 8583380..7026e23 100644 | |
--- a/rails/app/models/speaker.rb | |
+++ b/rails/app/models/speaker.rb | |
@@ -13,8 +13,8 @@ class Speaker < ApplicationRecord | |
def self.import_csv(filename) | |
CSV.parse(filename, headers: true) do |row| | |
speaker = Speaker.where(name: row[0], community: row[2]).first_or_create | |
- if row[3] && File.exist?(Rails.root.join('media', row[3])) | |
- file = File.open(Rails.root.join('media',row[3])) | |
+ if row[3] && File.exist?(Rails.root.join('media-import', row[3])) | |
+ file = File.open(Rails.root.join('media-import',row[3])) | |
speaker.media.attach(io: file, filename: row[3]) | |
speaker.save | |
end | |
diff --git a/rails/app/models/story.rb b/rails/app/models/story.rb | |
index 9958a63..26f22e2 100644 | |
--- a/rails/app/models/story.rb | |
+++ b/rails/app/models/story.rb | |
@@ -12,8 +12,8 @@ class Story < ApplicationRecord | |
speakerid = Speaker.where(name: row[2])&.first&.id | |
perm = row[9].blank? ? "anonymous" : "user_only" | |
story = Story.create(title:row[0], point_id: pointid, speaker_id: speakerid, permission_level: perm) | |
- if row[8] && File.exist?(Rails.root.join('media', row[8])) | |
- file = File.open(Rails.root.join('media',row[8])) | |
+ if row[8] && File.exist?(Rails.root.join('media-import', row[8])) | |
+ file = File.open(Rails.root.join('media-import',row[8])) | |
story.media.attach(io: file, filename: row[8]) | |
story.save | |
end | |
diff --git a/rails/config/database.yml b/rails/config/database.yml | |
index fdd4f94..1c1a37c 100644 | |
--- a/rails/config/database.yml | |
+++ b/rails/config/database.yml | |
@@ -1,54 +1,25 @@ | |
-# MySQL. Versions 5.1.10 and up are supported. | |
+# SQLite version 3.x | |
+# gem install sqlite3 | |
# | |
-# Install the MySQL driver | |
-# gem install mysql2 | |
-# | |
-# Ensure the MySQL gem is defined in your Gemfile | |
-# gem 'mysql2' | |
-# | |
-# And be sure to use new-style password hashing: | |
-# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html | |
+# Ensure the SQLite 3 gem is defined in your Gemfile | |
+# gem 'sqlite3' | |
# | |
default: &default | |
- adapter: mysql2 | |
- encoding: utf8 | |
- pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | |
- username: root | |
- password: | |
- host: mariadb | |
+ adapter: sqlite3 | |
+ pool: 5 | |
+ timeout: 5000 | |
development: | |
<<: *default | |
- database: app_development | |
+ database: db/development.sqlite3 | |
# Warning: The database defined as "test" will be erased and | |
# re-generated from your development database when you run "rake". | |
# Do not set this db to the same as development or production. | |
test: | |
<<: *default | |
- database: app_test | |
+ database: db/test.sqlite3 | |
-# As with config/secrets.yml, you never want to store sensitive information, | |
-# like your database password, in your source code. If your source code is | |
-# ever seen by anyone, they now have access to your database. | |
-# | |
-# Instead, provide the password as a unix environment variable when you boot | |
-# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database | |
-# for a full rundown on how to provide these environment variables in a | |
-# production deployment. | |
-# | |
-# On Heroku and other platform providers, you may have a full connection URL | |
-# available as an environment variable. For example: | |
-# | |
-# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" | |
-# | |
-# You can use this database configuration with: | |
-# | |
-# production: | |
-# url: <%= ENV['DATABASE_URL'] %> | |
-# | |
production: | |
<<: *default | |
- database: app_production | |
- username: app | |
- password: <%= ENV['APP_DATABASE_PASSWORD'] %> | |
+ database: db/production.sqlite3 | |
diff --git a/rails/config/storage.yml b/rails/config/storage.yml | |
index a10ec87..83d4333 100644 | |
--- a/rails/config/storage.yml | |
+++ b/rails/config/storage.yml | |
@@ -4,7 +4,7 @@ test: | |
local: | |
service: Disk | |
- root: "/media" | |
+ root: <%= Rails.root.join("tmp/storage") %> | |
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) | |
# amazon: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment