Skip to content

The "Hello Rails" app is a straightforward Rails API designed to demonstrate the creation of a RESTful API service with Ruby on Rails. This service's sole functionality is to fetch a random greeting from a predefined list stored in a PostgreSQL database.

License

Notifications You must be signed in to change notification settings

lily4178993/hello-rails-back-end

Repository files navigation

README

Table of Contents

About Project

The "Hello Rails" app is a Rails API that fetches a random greeting from a PostgreSQL database, demonstrating basic Rails API development. For a practical application, the "Hello React" app consumes this API to display greetings, showcasing a full-stack integration with React, Vite, and TailwindCSS.

See the "Hello React" app in action here.


Built With

  • Ruby on Rails
  • PostgreSQL

Tech Stack

  • Ruby: V3.2.2
  • Rails: V7.1
  • Database: PostgreSQL

Key Features

  • API endpoint to fetch a random greeting
  • PostgreSQL database integration
  • Simple and clean codebase focusing on RESTful API design

Getting Started

Prerequisites

  • Ruby
  • Rails
  • PostgreSQL

Setup

  1. Clone this repository
git clone https://github.com/lily4178993/hello-rails-back-end.git
cd hello-rails-back-end
  1. Check your Ruby version
ruby -v
  1. Install dependencies
bundle install
  1. Update your database informations Go to config/database.yml. Replace your_postgres_username and your_postgres_password with your database informations
      default: &default
      adapter: postgresql
      encoding: unicode
      pool: 5
      username: [your_postgres_username]
      password: [your_postgres_password]
      host: localhost
    
    development:
      <<: *default
      database: [your_database_for_development]
    
    test:
      <<: *default
      database: [your_database_for_test]
    
    production:
      <<: *default
      database: [your_database_for_production]

Install

Populate greetings data in the database by running the following commands:

rails db:create
rails db:migrate
rails db:seed

Usage

To start the server, run:

rails s

Navigate to http://localhost:3000/api/v1/greeting to see the API in action, returning a random greeting.

Tests

To run the test suite, execute the following commands:

rails db:migrate RAILS_ENV=test
rspec

Author

Future Features

  • Extend the API to include more diverse greetings
  • Implement other operations (e.g., adding or removing greetings)

Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a ⭐️ if this project helped you!

Acknowledgements

  • Ruby on Rails Community
  • PostgreSQL Team
  • Microverse

License

This project is MIT licensed.

(back to top)

About

The "Hello Rails" app is a straightforward Rails API designed to demonstrate the creation of a RESTful API service with Ruby on Rails. This service's sole functionality is to fetch a random greeting from a predefined list stored in a PostgreSQL database.

Topics

Resources

License

Stars

Watchers

Forks