Jack Moore

Email: jack(at)jmoore53.com
Project Updates

Code with the Flow

13 Nov 2019 » rails, react, frontend, backend, fullstack

Code with the Flow

Writing rails applications is often broken up between the frontend, routes, backends, and the database. It is a classic MVC framework.

The way I often write is writing the frontend first starting with the react components in the app/webpack folder. Any fetch request in the frontend is then directed to the rails applications where the rails application looks at the routes. In the routes file config/routes.rb I configure the fetched route to go to a specific controller and from the controller I then make calls to the database.

It looks something like the following: 1) app/webpack/console.jsx -> makes a fetch request to http://127.0.0.1/data/index 2) config/routes.rb takes the request -> directs it to a view or controller depending on the controller data app/controllers/data 3) data#index method in the controller with a code block calling to the ORM 4) ModelName < ApplicationRecord

Gist

Start from the frontend and work your way through the application. When one piece is complete, move to the next frontend component.

© Jack Moore - This site was last built Fri 30 Aug 2024 12:31:24 PM EDT