Skip to content

Exercise to practice setting up a Rails API project.

Notifications You must be signed in to change notification settings

vanmars/quotes_api

Repository files navigation

Movie Quotes API

25 October 2020

Rails API of movie quotes

By Vanessa Stewart

Description

This is a follow-along lesson for Epicodus to practice creating a Rails API project. This project uses the rails new <project_name> --api command to set up an api project.

  • It has a quotes model, that validates author and content properties.
  • It contains a search scope method, so that users can search for a quote by author name in the 'get /quotes' route.
  • It handles exceptions for faulty post and put requests with clear error messages to the user.
  • It provides success messages for successful put, and delete requests.
  • It handles excpetions and json rendering through the use of ruby concerns and modules.
  • It uses the Factory Bot gem for DRYing up tests
  • It has a spec/requests folder to handle get and post request testing.

Setup/Installation Requirements

  1. Install Rails
  • For this project, you will need Ruby. Follow the directions here for setting up Ruby.
  • Install Rails on your machine with the following terminal command gem install rails -v 5.2.0
  1. Clone Repo and Install Bundler
  • Navigate to the directory on your local computer where you would like to clone this repo.
  • Clone this repo using the git clone command in terminal/command line.
  • Navigate to the cloned folder and run gem install bundler to install Bundler, which will mange all gem installations for our project.
  • Run bundle or bundle install in your command line to download all dependencies. (If you add additional gems later, you will need to run bundle update <gem name>.)
  1. Set Up Database
  • Run rake db:setup in the terminal. This is akin to running the following rake tasks all at once: db:create(creates the dev and test databases for the current env), db:schema:load (recreates the database from the schema.rb file), and db:seed(runs the db/seed.rb file).
  1. Open in Text Editor
  • Open the cloned repo in a text editor of your choice.
  • To Run Tests: While in the root directory of this project, run rspec in your command line.
  • To Run the App in Browser: While in the root directory of the project, run rails s in the terminal. This will start a server, which you can access by entering localhost:3000 in your browser.

Known Bugs

There are no known bugs at this time.

Technologies Used

  • Ruby
  • Rails
  • Special Ruby Gems: Factory Bot, Faker, Launchy, Pry, RSpec
  • Postgres/psql

License

Copyright (c) 2020 Vanessa Stewart

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Exercise to practice setting up a Rails API project.

Topics

Resources

Stars

Watchers

Forks