Skip to content

Instantly share code, notes, and snippets.

@kamiboers
Forked from Carmer/Intro_to_sinatra_check.md
Last active March 22, 2016 04:56
Show Gist options
  • Save kamiboers/95bf2c71e662044daa41 to your computer and use it in GitHub Desktop.
Save kamiboers/95bf2c71e662044daa41 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 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.

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

Using an .erb file to embed ruby alongside html tags. <%= #ruby_code %> displays the results of the ruby code, <% #ruby_code %> does not display the results of the ruby code.

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

The data comes in as a hash called "params".

5. What are params?

Any information that is received from a view form can be accessed in the params hash by name.

@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