Skip to content

Instantly share code, notes, and snippets.

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

Introduction to Sinatra

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

The server is a file that allows the receiver and the responder to give and get the proper out put based on the verb (POST, GET, PUT, DELETE) and the path. Whatever you put in your server file determines what the client gets back.

2. How do you pass variables into the views?

The variable that you are trying to pass needs to be considered in the “Get block” erb represents the file that you want to view

Example;

get ‘/’ do @something = one thing erb: index end

this erb(index would be based on what you would want to pass in; erb (:index, :local =>{@something = one thing}

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

<% ruby_code_here%> or <%= ruby_code_here%> the = represents what will be projected on web(from Server to View). You would not want to use the = for conditions, if/else, when, whiles, etc.

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

Data submitted by users in a form comes in as a hash called “params”.

@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