Skip to content

Instantly share code, notes, and snippets.

@kamiboers
kamiboers / cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:20 — forked from rwarbelow/cfu_crud_in_sinatra.markdown
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD.

CRUD stands for Create, Retrieve, Update, and Delete. These are the major functions of a database application.

  1. There are seven verb + path combinations that are necessary in a basic Sinatra app in order to provide full CRUD functionality. List each of the seven combinations, and explain what each is for.

Get, render index of objects Get, render data object by id Get, render form to post new data object Post, redirect to new data object (with id)

Introduction to Sinatra

1. What is the purpose of the server file (routing)?

The server file is the gatekeeper that receives and appropriately responds to client requests based on the verb (GET, POST, DELETE, PUT) and the path present in the request.

2. How do you pass variables into the views?

By adding them in a hash erb(:index, :locals => {:variable => variable}) for local variables, or as instance variables s/a @variable.