Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy #22

Merged
merged 13 commits into from
Mar 7, 2023
Merged
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ node_modules

# Ignore master key for decrypting credentials and more.
/config/master.key

/config/credentials/production.key
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ gem 'jbuilder'
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Google Cloud Storage for Active Storage
gem 'google-cloud-storage'

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

Expand Down
60 changes: 60 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,56 @@ GEM
debug (1.7.1)
irb (>= 1.5.0)
reline (>= 0.3.1)
declarative (0.0.20)
digest-crc (0.6.4)
rake (>= 12.0.0, < 14.0.0)
diff-lcs (1.5.0)
dotenv (2.8.1)
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
railties (>= 3.2)
erubi (1.12.0)
faraday (2.7.4)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
globalid (1.1.0)
activesupport (>= 5.0)
google-apis-core (0.11.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.19.0)
google-apis-core (>= 0.9.0, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.1)
google-cloud-storage (1.44.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.19.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.3.0)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
httpclient (2.8.3)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
importmap-rails (1.1.5)
Expand All @@ -131,10 +173,12 @@ GEM
net-smtp
marcel (1.0.2)
matrix (0.4.2)
memoist (0.16.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.17.0)
msgpack (1.6.0)
multi_json (1.15.0)
net-imap (0.3.4)
date
net-protocol
Expand All @@ -147,6 +191,7 @@ GEM
nio4r (2.5.8)
nokogiri (1.14.2-x86_64-linux)
racc (~> 1.4)
os (1.1.4)
pg (1.4.5)
pry (0.14.2)
coderay (~> 1.1)
Expand Down Expand Up @@ -197,7 +242,13 @@ GEM
regexp_parser (2.7.0)
reline (0.3.2)
io-console (~> 0.5)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.5)
ruby2_keywords (0.0.5)
rspec-core (3.12.1)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.2)
Expand All @@ -220,6 +271,11 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
signet (0.17.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
Expand All @@ -231,12 +287,14 @@ GEM
railties (>= 6.0.0)
thor (1.2.1)
timeout (0.3.2)
trailblazer-option (0.1.2)
turbo-rails (1.3.3)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uber (0.1.0)
web-console (4.2.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -246,6 +304,7 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webrick (1.8.1)
websocket (1.2.9)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
Expand All @@ -265,6 +324,7 @@ DEPENDENCIES
database_cleaner
debug
dotenv-rails
google-cloud-storage
importmap-rails
jbuilder
jwt
Expand Down
3 changes: 2 additions & 1 deletion app/models/trip.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Trip < ApplicationRecord
include Rails.application.routes.url_helpers
validates :price, presence: true, numericality: { only_float: true, greater_than_or_equal_to: 0 }
validates :rating, presence: true
validates :rating, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
Expand All @@ -15,6 +16,6 @@ class Trip < ApplicationRecord
has_many :reservations

def image_url
Rails.application.routes.url_helpers.url_for(image) if image.attached?
url_for(image)
end
end
Empty file modified bin/rails
100644 → 100755
Empty file.
12 changes: 12 additions & 0 deletions config/capstone.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "service_account",
"project_id": "final-capstone-379820",
"private_key_id": "e9c30befb58a80edbaea367bacc7507b370e3c74",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCPgTZl1m3Rjf22\njxpzrR16xOyjtnYlmwW0EStcMde82H2FNoAn7M48HRCsh65CI1ONIFXhrKu0bvub\nC5eyhXzibklg47+SN3yCF1M/O4p3fj2223eaj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GyNN3TIDKahpc\nbT4j+qMwXr1/v9uaYglXvnxiukTAGsw/116er+0YBWbBJidXbk1+tIOZVQKBgQCA\n2x+X568OWShWGQw6/j6IDHDHRVj5ATqQZl9lccbaqahasmMqH9/FXs9pbo8qA+tz\nHI0l+3ZlSdz4RAZPjPAbx92oxfFbG3dx3Z2gll8G0pK/1wQ+t7oRFu5/p0VBkpvQ\nMbPFA63rlWOKcDPCQc4+rUBItMK38v99mbZ91EKiaQKBgQCOIR9dSf4GSNrDiLxc\nxlgDjOZx6hj9tdbc3UA1nK5v87L2VW1msoOZ5xV8NFGl4MdpeABeLPww7tiTMntv\nbd0xdnIiLxvhts3ucUrvBUOAIDfDyWpk7oJPq0TDMMPwEoIN/qhEiySD9yNSEEYm\n+2oRO8Zz58vy4q/Ky2gyMzImmQ==\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "106511192818806657237",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/capstone%40final-capstone-379820.iam.gserviceaccount.com"
}
2 changes: 1 addition & 1 deletion config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
U6tCoy/AWK/+XsPy2+pSPJTFiTgblAPDhkYWqOAQZNDtf6oAtDSsrOzoFtgPs0x5oTTLp2QxzUjdpfCKnsy2i/8xT3P3d2d5L/KeHXdNui1FF0VrcfBnh2/ZRaytPcQR2g3R8mqJyH7ZaNRB5KCxksE4hPH931QDH25BwW0rO1s3KsJ2Kg9dnvAP+z81lDzdD/+InDP+RYI+hFI3pjBMQBQvhwJzYxy+qUI7h+lhvoJlQS28Dn/exhnTRsiNPKVJtzTXQ/ECRKwJg7mme/viK0TuoqeJlevWxVJPk0g3KCC+Ob890Yfd9wGPo/HIlEQPKKHKzXIf8tqVR5YwF8/inMqp3mXN8gM+8QiS8vzq3tE0ztyluAjOvvjQQJ3tKNR+6qt57t9ToN9b43mQeVw1B6HT3mpOjQ37S0jS--L49p4wlx75nCd7Lc--1gwnUDR8S4VvCwgJDIhQRw==
YcAU3IfLoyLlf9hD6u3WnZtvuS125hp3M5KTYaUE2H8ngHl8kX3EXdf6RG222R/EHcIH2K9GfEapotSFUNKwQl658Y/iY+cmg1UuDrGGP3ckVXFeQNcHo0HoLNfL4bHNUoNdJRooyZe+3IEM/2VkNp2eW6RNrQ+bQKklg00WHD0U+OFaaY4GSDCjUPQ7Qliw7eRghlotdVL5plVTWYhH6hMxQNYTUV0Jhaouiy+WZPIG1TJ7WXGnetknRhQ9J+vKXVW6gkG/aKIdyChbC4lj1zSCvwWqk+8XMqmmaYsYPkVYK0DuyJXGGzAi+Ps/49ZD73u9LG2lOXW33LHE/ZCR6eWrVjU1pd+4VJEeIlJxePr27YavaQWvAfJdsvZegZBHBDmt7H2OD1BvlHLYojU4rF18RgmNQaSXqWp+hucMpnAXEeVjWlw3Dh1xdvf9ek7Jpwm/uISLcNXuFJUPGkbEiIJvXsf7HzH1JvNT5Xvv3ewjKeM=--TL9PfPX6GD/c7iQN--k/VXf/LIIbfTcIAfCHKeIA==
6 changes: 3 additions & 3 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ test:
#
production:
<<: *default
database: final_capstone_backend_production
username: final_capstone_backend
password: <%= ENV["FINAL_CAPSTONE_BACKEND_DATABASE_PASSWORD"] %>
database: <%= ENV['DB'] %>
username: shaker
password: SHaker@100
7 changes: 6 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Code is not reloaded between requests.
config.cache_classes = true
config.secret_key_base = ENV['SECRET_KEY_BASE']

# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
Expand All @@ -26,12 +27,15 @@
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?

# Adding host link to production
# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# Config require master key
config.require_master_key = true
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "https://assets.example.com"

Expand All @@ -40,7 +44,8 @@
# 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 = :google_cloud_storage
ENV["RAILS_ACTIVE_STORAGE_SERVICE"] = "google_cloud_storage"

# Mount Action Cable outside main process or domain.
# config.action_cable.mount_path = nil
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Defines the root path route ("/")
# root "articles#index"
default_url_options :host => "https://capstone-backend-gz9j.onrender.com"
namespace :api do
namespace :v1 do
post 'auth/sign_up', to: 'authentication#signup'
Expand All @@ -11,5 +12,5 @@
resources :trips, only: [:index, :show, :create, :update, :destroy]
resources :reservations, only: [:create, :index]
end
end
end
end
10 changes: 5 additions & 5 deletions config/storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ local:
# bucket: your_own_bucket-<%= Rails.env %>

# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket-<%= Rails.env %>
google_cloud_storage:
service: GCS
project: final-capstone-379820
credentials: <%= Rails.root.join('config', 'capstone.json') %>
bucket: new-microverse

# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
def change
# Use Active Record's configured type for primary and foreign keys
primary_key_type, foreign_key_type = primary_and_foreign_key_types

create_table :active_storage_blobs, id: primary_key_type do |t|
t.string :key, null: false
t.string :filename, null: false
t.string :content_type
t.text :metadata
t.string :service_name, null: false
t.bigint :byte_size, null: false
t.string :checksum

if connection.supports_datetime_with_precision?
t.datetime :created_at, precision: 6, null: false
else
t.datetime :created_at, null: false
end

t.index [ :key ], unique: true
end

create_table :active_storage_attachments, id: primary_key_type do |t|
t.string :name, null: false
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
t.references :blob, null: false, type: foreign_key_type

if connection.supports_datetime_with_precision?
t.datetime :created_at, precision: 6, null: false
else
t.datetime :created_at, null: false
end

t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end

create_table :active_storage_variant_records, id: primary_key_type do |t|
t.belongs_to :blob, null: false, index: false, type: foreign_key_type
t.string :variation_digest, null: false

t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end

private
def primary_and_foreign_key_types
config = Rails.configuration.generators
setting = config.options[config.orm][:primary_key_type]
primary_key_type = setting || :primary_key
foreign_key_type = setting || :bigint
[primary_key_type, foreign_key_type]
end
end
2 changes: 1 addition & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.