Skip to content

Instantly share code, notes, and snippets.

@jwashke
Forked from Carmer/Intro_to_sinatra_check.md
Last active March 22, 2016 04:02
Show Gist options
  • Save jwashke/ac3b330d81c13aacc566 to your computer and use it in GitHub Desktop.
Save jwashke/ac3b330d81c13aacc566 to your computer and use it in GitHub Desktop.

Introduction to Sinatra

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

The server file serves as the main point of contact between the client and the server. The server file takes in the http request from the client and routes the client to the proper page base on the verb and the path of the http request.

2. How do you pass variables into the views?

Instance variables are useable in the view when it is rendered. local variables you pass in using a key value hash erb(:index, locals => { :name_in_view => name_in_server }

3. How can we interpolate ruby into a view (html)?

Using ERB (Embedded RuBy) in the server call the erb method and tell it the view you want it to render. erb :index

4. In what format does data come in from a view/form? What do we call it?

A hash called params the name in the form/view is the key in the hash that the value is stored at. You can access the value using either a symbol or string of the key.

5. What are params?

Input taken in by the client often through html forms on a web page.

@Carmer
Copy link

Carmer commented Mar 22, 2016

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment