Skip to content

Commit 461c2ee

Browse files
authored
Update README.md
API versioning
1 parent de49a77 commit 461c2ee

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Rails-API-React-Tutorial 💻 [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
22

33
Hey! This is a super-easy to follow Rails/React API tutorial that is fully in depth from start to finish. This guide shows you how to install Ruby
4-
and Rails 5 in a Virtual Box, React JS via create-react-app and connecting the frontend and backend.
4+
and Rails 5 in a Virtual Box, React JS via create-react-app and connecting the frontend and backend.<br>
5+
6+
<p align="center">
7+
<img width="460" height="320" src="https://media.giphy.com/media/oZKuC9DJUK2yc/giphy.gif">
8+
</p>
59

610
## Table of Contents
711
* Downloading Virtual Box
@@ -212,3 +216,35 @@ Rails.application.routes.draw do
212216
end
213217
```
214218
which allows us to call the json data from ```ruby localhost:3000/api/v1/movies```
219+
220+
221+
6. Let's seed our sqlite database with some classic movies so we can practice getting data with GET requests to the API.
222+
223+
Copy and paste the following data to your ```ruby config/seeds.rb``` file.
224+
225+
```ruby
226+
Movie.create(name: "The Nightmare Before Christmas", rating: 5)
227+
Movie.create(name: "Titanic", rating: 5)
228+
Movie.create(name: "Venom", rating: 4)
229+
Movie.create(name: "A Quiet Place", rating: 5)
230+
Movie.create(name: "Nobody's Fool", rating: 2)
231+
Movie.create(name: "Suspiria", rating: 4)
232+
Movie.create(name: "Hereditary", rating: 4)
233+
Movie.create(name: "Office Space", rating: 5)
234+
Movie.create(name: "Elf", rating: 4)
235+
Movie.create(name: "Dawn of the Planet of the Apes", rating: 3)
236+
Movie.create(name: "Secret life of Pets", rating: 4)
237+
Movie.create(name: "Overlord", rating: 3)
238+
Movie.create(name: "Wonder Woman", rating: 5)
239+
Movie.create(name: "Bohemian Rhapsody", rating: 4)
240+
Movie.create(name: "Ocean's 8", rating: 5)
241+
```
242+
243+
Seed the DB using ```ruby rails db:seed && rails db:migrate ```
244+
245+
7. Test the API using a GET request.
246+
247+
Start your Rails server ```rails s``` and navigate to ```localhost:3000/api/v1/movies``` and if it is successful you should see the following JSON output: <br><br>
248+
249+
(Optional) I'm using a pretty JSON viewer for chrome which you can download [here.](https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc)
250+
<a href="http://tinypic.com?ref=2m60ahx" target="_blank"><img src="http://i63.tinypic.com/2m60ahx.png" width="450" height="450" border="0" alt="Image and video hosting by TinyPic"></a>

0 commit comments

Comments
 (0)