Giter VIP home page Giter VIP logo

culture-park's Introduction

Project Template: React/Rails API

Description

This project is scaffolded so that you can build a React frontend and Rails backend together, and easily deploy them to Heroku.

Requirements

  • Ruby 2.7.3
  • NodeJS (v14 or higher), and npm
  • Heroku CLI
  • Postgresql

See Environment Setup below for instructions on installing these tools if you don't already have them.

Setup

Fork and clone this repository.

Then run:

bundle install
rails db:create
npm install --prefix client

You can use the following commands to run the application:

Make sure to also update this README to include documentation about your project. Here's a list of some awesome readmes for inspiration.

Deploying

This application has all the starter code needed to help you deploy your application to Heroku. It's recommended to deploy your project early and push up changes often to ensure that your code works equally well in production and development environments.

To deploy, first log in to your Heroku account using the Heroku CLI:

heroku login

Create the new Heroku app:

heroku create my-app-name

Add the builds for Heroku to run the Rails app on Ruby and build the React app on Node:

heroku buildpacks:add heroku/nodejs --index 1
heroku buildpacks:add heroku/ruby --index 2

To deploy, commit your code and push the changes to Heroku:

git add .
git commit -m 'Commit message'
git push heroku main

Note: depending on your Git configuration, your default branch might be named master or main. You can verify which by running git branch --show-current. If it's master, you'll need to run git push heroku master instead.

Any time you have changes to deploy, just make sure your changes are committed on the main branch of your repo, and push those changes to Heroku to deploy them.

You can view your deployed app with:

heroku open

Environment Setup

Ruby

Ensure you are running the latest Ruby release supported by Heroku. At the time of writing, that's 2.7.3. You can verify with:

ruby -v

If you don't see 2.7.3, you can install it and set it as the default version:

rvm install 2.7.3
rvm --default use 2.7.3

You should also install the latest versions of bundler and rails:

gem install bundler
gem install rails

Install NodeJS

Verify you are running a recent version of Node with:

node -v

If your Node version is less than 14, update it with:

nvm install node

You can also update your npm version with:

npm i -g npm

Install the Heroku CLI

Follow this guide to install Heroku CLI (if you don't already have it):

Install Postgresql

Heroku requires that you use Postgresql for your database instead of SQLite. Postgresql (or just Postgres for short) is an advanced database management system with more features than SQLite. If you don't already have it installed, you'll need to set it up.

To install Postgres for WSL, follow this guide:

To install Postgres for OSX, you can use Homebrew:

brew install postgresql

Once Postgres has been installed, run this command to start the Postgres service:

brew services start postgresql

Troubleshooting

If you ran into any errors along the way, here are some things you can try to troubleshoot:

  • If you got a server connection error when you tried to run rails db:create, one option for solving this problem for Mac users is to install the Postgres app. To do this, first uninstall postgresql by running brew remove postgresql. Next, download the app from the [Postgres downloads page][] and install it. Launch the app and click "Initialize" to create a new server. You should now be able to run rails db:create.
  • If your app failed to deploy at the build stage, make sure your local environment is set up correctly by following the steps at the beginning of this lesson. Check that you have the latest versions of Ruby and Bundler, and ensure that Postgresql was installed successfully.
  • If you deployed successfully, but you ran into issues when you visited the site, make sure you migrated and seeded the database. Also, make sure that your application works locally and try to debug any issues on your local machine before re-deploying. You can also check the logs on the server by running heroku logs.

For additional support, check out these guides on Heroku:

  • [Deploying a Rails 6 App to Heroku][heroku rails deploying guide]
  • [Rails Troubleshooting on Heroku][troubleshooting guide on heroku]

culture-park's People

Contributors

git-it-gyrl avatar ihollander avatar lizbur10 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.