Skip to content

neondatabase/guide-neon-rails

Repository files navigation

Running migrations in a Neon-Rails project

This application is a simple Ruby on Rails project using the Neon Postgres database. It returns a list of authors and books written by them. We illustrate how to generate and run schema change migrations.

To build this project from scratch, check out the guide in Neon's documentation.

Set up locally

You will need the following:

  • A Neon account and a project
  • Ruby 3.0 or higher
  1. Clone this repository:
git clone https://github.com/neondatabase/guide-neon-rails
  1. Navigate to the project directory and install the project dependencies:
cd guide-neon-rails
bundle install
  1. Create a .env file in the root of the project and add the following environment variable with your Neon database URL:
DATABASE_URL=
  1. Run the Rails database migrations:
rails db:migrate
  1. Seed the database with sample data:
rails db:seed
  1. Start the Rails server:
rails server
  1. Visit http://localhost:3000 in your browser to see the list of authors and books. Or use curl to see the html payload in your terminal:
# Page with the list of authors
curl http://localhost:3000/authors

# Page with the list of books by author with id 1
curl http://localhost:3000/books/1

About

Example guide for Neon with Rails

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published