Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
images
README.md
rails-api_notes.pdf

README.md

LESSON: rails-api


2018-07-10

OBJECTIVES

By the end of this, developers should be able to:

  • Explain why an API is necessary.
  • List some of the responsibilities of a typical API, and identify which components within MVC map to those responsibilities.
  • Diagram the process flow from Client through Database and back
  • Map MVC roles to specific components of Rails.
  • Indicate where different types of files can be found within a Rails application.

VOCABULARY

Application Programming Interface (API): Methods exposed by an application to allow a user to interact with the necessary functions of the application without having to understand / interact witht the underlying code of the application

Front End / Client: Typically a browser or an app which makes requests to a server and displays an interactive UI to the client, allowing the client to interact with data stored on the server.

Back End / Server: The service which takes requests from a client, and completes CRUD actions requested by the client. Part of the server has the role of the controller, which implements CRUD actions requested by the client.

Routes: The part of a url that comes after the domain, ie http://www.mydomain.com/<here is where the route goes>/. Routes are closely tied by their name to the resources on the server that they interact with. For example, a /books/ route could allow interaction with a books table in the database that stores book information.

Model - View - Controller Pattern (MVC): An architectural pattern that specifies how the data Model and the client View interact through a Controller. This pattern is what is used to build Ruby on Rails APIS.

Model: The data model. How the various aspects of the real world we want to keep track of are modeled, just like we model real world objects using objects in various programming languages, and a description of dependencies and interactions between model objects. A model is an abstract concept describing data organization, whereas a database in how a model is implemented in code. It is important to note that the model is not designed with any specific considerations about the view in mind. It is "agnostic" to how the view is constructed.

View: The information from the model that is represented to the user on the front end, along with any other UI elements that allow the user to interact with the app / page.

Controller: The interface between the model and the view. Typically on a server, the controller handles interacting with the database and performing CRUD actions, and responding back to the client with information during HTTP requests.

Database: A data structure implemented in code which handles persisting data in the structure specfied by a data model, as well as describing relationship between different data objects, and handling CRUD actions on it's own data.

Persist: To allow data to be semi-permanently stored. Databases persist data, ie they semi-permanently store it (only semi-permanent because database records can be deleted).

Record: One single entry in a database. An example of a record might be the object describing a single person and their in a Persons database table.

Serializer: The part of the server which formats the data returned by the server to the client in the response.

Ruby on Rails (Rails): A full-featured back-end web server framework written in Ruby that allows for very quick setup and automated modification of a server project.

NOTES

  • MVC model: Model-View-Controller
  • Breaking down a server into parts:

Server sequence