For our “Engineering All Hands” meetings at Hipcamp, we have someone new run it every week. That person is picked at random using some manual process. Let’s make a web app to do that for us. Make sure you have recent versions of Ruby, Ruby on Rails, and PostgreSQL installed. Installation is outside the scope of this guide, but if you’re on macOS you can use Homebrew and rbenv to help with installation and versioning.
Check your versions.
Terminal
ruby -v
rails -v
postgres -V
Create a new API only Rails application.
Terminal
rails new all_hands --database=postgresql --api
cd all_hands
g add .
g commit -m "Initial commit" -m "rails new all_hands --database=postgresql --api"
Start the server.
Terminal
bin/rails s
Let the server run and visit http://localhost:3000.
You should see a lot of red and probably something about the database. That’s good. The application is running. We just need to run a few more commands. Every command from here on out will assume that you’re in the root directory of the project.
If you see ActiveRecord::ConnectionNotEstablished, start the service.
Terminal
brew services start postgresql
If you see ActiveRecord::NoDatabaseError, create the database.
Terminal
bin/rails db:create
bin/rails db:migrate
Finally, refresh the page and you’ll see a Rails welcome screen. In your project directory, you might notice a new file named db/schema.rb. Whenever we have uncommitted changes and seem to be at a good stopping point, you’ll see a box like the one below.
âś… Make a commit
Next: Chapter 2 - The User