Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save patrickwhardy/1fbdb4f19f4dfb416f9f to your computer and use it in GitHub Desktop.
Save patrickwhardy/1fbdb4f19f4dfb416f9f to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD. Create, read, update, destroy - this is the base functionality that all applications should provide
  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. Get, /tasks - shows all tasks Get, /tasks/:id - shows one task Get, /tasks/new - shows form for task creation Post, /tasks - submits task content and creates object Get, /tasks/:id/edit - shows form to edit task info Put, /task/:id - submits changes to task info Delete, /task/:id - delets task
  3. Why do we use set method_override: true? because we want to override the default method for our forms - change from post?
  4. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>. name represents what we will tell params we are looking for and value represents the contents of the object found at value
  5. What are params? Where do they come from? params is the hash that contains all content from our YAML database
@patrickwhardy
Copy link
Author

figured it out - enter is not creating new lines so the formatting is just wonky

@Carmer
Copy link

Carmer commented Mar 23, 2016

Params is a hash of data that comes from a request. The request can be sent from a page that had a form and the data was gather from the form and passed through to the controller. Params can also be sent through the url. params are anything after a ? in the url and are separated by a &. For example: www.thingplace.com/things/5?name=dog&description=cute This example would give us params like this: params = {"name" => "dog", "description" => "cute"}

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