Step-By-Step Guide to Using Javascript Front-End with a Rails App Backend to Make Your Own API

go from this

to this

or even this

without this

  1. create and fill the db/migrate/ migrations rb files that inherit from ActiveRecord::Migration
  2. run rails db:migrate. You will see in the terminal if they were successfully created or if there was an (probably syntax in the create_migration file) error.
  3. confirm the db/schema.rb looks right
  4. create and fill the db/seeds.rb files
  5. run rails db:seed
  6. use rails c or rails console (or database browser software) to confirm the database has been seeded properly.
  7. add appropriate routes in config/routes.rb on the backend
  8. create the app/models model rb files that inherit from ApplicationRecord which inherits from ActiveRecord::Base and designate any relationships
  9. create the matching controllers inheriting from ApplicationController which inherits from ApplicationController:::Base
  10. create and fill app/services/ serializer.rb file for the model
  11. fill in matching controller actions in the corresponding controller.rb in app/controllers/ to pull data from the database and render json: with the data or with plain text string. no need for instance variables because we’re not passing the data to erb views.
  12. run rails s to start up server
  13. confirm at your local server address that the API is rendering data




Product manager | Leading with empathy.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Exactly my point.

Making a dynamic Image Viewer Panel with Comet’s JavaScript SDK

Is AJAX getting replaced by fetch API()?

Offline caching with serviceworkers

Google Summer of Code: Week 2

Browser-based Behavor Graph Editing

The Bonomi Tech-Stack

Javascript ES2019 Features

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Product manager | Leading with empathy.

More from Medium

Developing Your First Full Stack Application (React & Ruby on Rails)

Real-time public transit schedule app based on CTA API, with Rails and React

Building A Simple Login System with Authentication and Ruby on Rails

Ruby on Rails — Phase 4 Project