Skip to content

Instantly share code, notes, and snippets.

@seeker105
Forked from Carmer/Intro_to_sinatra_check.md
Last active March 22, 2016 04:55
Show Gist options
  • Save seeker105/24385343d23bd0825852 to your computer and use it in GitHub Desktop.
Save seeker105/24385343d23bd0825852 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 acts as the executable code. It processes the incoming HTTP message and generates the correct output to return to the user.

2. How do you pass variables into the views?

You declare an instance variable. When the server file is executed it inherits the current state, including the instance variables. OR create a hash called :locals with the local variables you want to pass in. Pass the locals hash to the erb method as an argument, along with the erb filename.

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

Using the Ruby interpolation tags: <%= %> and <% %>. The tag with the equals sign will display its result, while the tag w/o the = will just execute the logic.

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

It comes in as a hash called 'params' where the keys are the names of the data fields and the values are the data elements entered into the fields.

5. What are params?

'params' are the data elements collected using a form and passed using an HTTP message.

@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