Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notmarkmiranda/94e66694bff05c5aa5fe to your computer and use it in GitHub Desktop.
Save notmarkmiranda/94e66694bff05c5aa5fe to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD. - Create, Read, Update, Delete

  2. 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. a. (get - /folder) - get all items in folder b. (get - /folder/:id) - get single item in folder c. (get - /folder/new) - get view with form to create new view d. (post - /folder) - post new item e. (get - /folder/:id/edit) - get form to edit exisiting item f. (put - /folder/:id) - update existing item g. (delete - /folder/:id) - delete item based on id

  3. Why do we use set method_override: true? - to allow us to give buttons another method instead of POST

  4. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>. - name is what is going to be sent when the form is submitted, value is what populates the text field.

  5. What are params? Where do they come from? - params come from form submission? i think?

@Carmer
Copy link

Carmer commented Mar 23, 2016

Params come from submitting a form, or they can also be sent through in the url. If you see a ? in a url - it signals the start of params. So - if we have a url like this: www.thingplace.com/places/5?name=ocean&description=wet then we will get params like: params = { "name" => "ocean", "description" => "wet"}

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