Rails + React + Redux - Pt 7
While I plan to revisit the previous posts' gists for refactoring- I'll move ahead in the project. I can now seed the database and view the data in cleaned JSON thanks to JSONView. I can also start setting up some structure on the front end.
Let's get started!
I call the scraping and association methods in db/seeds.rb and run the following commands to get the data.
$ rails db:create && rails db:migrate && rails db:seed
Then voila! start your engines! We have data to see at localhost:3000/api/v1/
$ rails s
... is all you need to ensure everything is working to this point. The queens, seasons, and episodes paths will all show their nested associations.
With the backend serving the JSON, a proxy needs to be set inside package.json from within the frontend directory. This will allow for communication between the React and Rails aspects of the project.
I decided to use the api/v1 convention with future versioning in mind. When I run foreman to start both the React and Rails servers, it will serve the Rails server on the 5000 port and the React server on the 5100 port.
In the next post I will start the foundation for React, Redux, and Thunk on the front end.
Top comments (0)