Skip to content

Kishanpa3/OakCreekDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OakCreekDB

OakCreekDB is a web-based DBMS for managing Oak Creek Zoological Conservatory's animal information.

Installation

Make sure you have installed all of the following prerequisites on your (Ubuntu) Linux machine:

Install Ruby and Rails:

$ rvm install ruby-2.6.3
$ rvm use 2.6.3
$ gem install rails --version=6.0.0

Install Bundler 2:

$ gem install bundler

Install the gems:

$ bundle install --without production

Configuration

First-time local database creation and initialization:

$ rails db:migrate
$ rails db:seed

If using Amazon S3 for file uploads, put your S3 credentials in application.yml, and setup CORS:

S3_BUCKET: "..."
S3_ACCESS_KEY_ID: "..."
S3_SECRET_ACCESS_KEY: "..."
S3_REGION: "..."

SHRINE_SECRET_KEY_BASE: "..."

For more information, check out our project setup guide.

Deployment

If you have deployed to Heroku before, just create a new app container with heroku create. If this is your first time deploying to Heroku, you will need to do two things. First, sign up for a free Heroku account. Then set up ssh keys to securely communicate with Heroku for app deployments. The three basic commands you need are the following, but see the Heroku page for more details.

$ ssh-keygen -t rsa
$ heroku login
$ heroku keys:add

Once your keys are set up (a one-time process), you should be able to create an "app container" on Heroku into which you'll deploy:

$ heroku create

Finally, deploy the app to Heroku:

$ git push heroku master

Just as we ran rails db:migrate and rails db:seed to do first-time database creation locally, we must also cause a database to be created on the Heroku side:

$ heroku run rails db:migrate

and

$ heroku run rails db:seed

Now you should be able to navigate to your app's URL.

Source

AWS S3 Setup

You'll need to create an AWS S3 bucket, which is where the uploads will be stored. See this walkthrough on how to do that.

Next you'll need to configure CORS for that bucket, so that it accepts (multipart) uploads directly from the client. In the AWS S3 Console go to your bucket, click on the "Permissions" tab and then on "CORS configuration". There paste in the following:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <CORSRule>
    <AllowedOrigin>https://my-app.com</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>PUT</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>Authorization</AllowedHeader>
    <AllowedHeader>x-amz-date</AllowedHeader>
    <AllowedHeader>x-amz-content-sha256</AllowedHeader>
    <AllowedHeader>content-type</AllowedHeader>
    <ExposeHeader>ETag</ExposeHeader>
  </CORSRule>
  <CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
  </CORSRule>
</CORSConfiguration>

Replace https://my-app.com with the URL to your app (in development you can set this to *). Once you've hit "Save", it may take some time for the new CORS settings to be applied.

Source

References

  • Webpacker - Manages app-like JavaScript modules in Rails
  • Shrine - File attachment toolkit for Ruby applications
  • Devise - Flexible authentication solution for Rails based on Warden

License

This project is licensed under the terms of the MIT license.