Skip to content

Instantly share code, notes, and snippets.

@MsJennyGiraffe
Forked from Carmer/crud.markdown
Last active May 10, 2016 23:16
Show Gist options
  • Save MsJennyGiraffe/3bae8e80fdff023088679957cff1026e to your computer and use it in GitHub Desktop.
Save MsJennyGiraffe/3bae8e80fdff023088679957cff1026e to your computer and use it in GitHub Desktop.
  1. Define CRUD.
  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.
  3. Why do we use set method_override: true?
  4. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>.
  5. What are params? Where do they come from?
@MsJennyGiraffe
Copy link
Author

MsJennyGiraffe commented May 10, 2016

CRUD is an acronym that stands for: Create, Read, Update, and Delete.
Seven path combinations for full CRUD functionality are:

  • GET and '/tasks'
    • This allows the user to see all the tasks that are in the database.
  • GET and '/tasks/:id'
    • This allows the user to see a task with the specific task ID given from the user.
  • GET and '/tasks/new'
    • Displays a form that a user can fill out with information to create a new task.
  • POST and '/tasks'
    • Allows the user to submit the form that was filled out to create a new task with that information.
  • GET and '/tasks/:id/edit'
    • Allows the user to access a task with a specific id in order to edit partial information about the task
  • PUT and '/tasks/:id'
    • Allows the user change information about the task that they accessed with a specific ID.
  • DELETE and '/tasks/:id'
    • Allows the user to delete a task.

The name is asking for the title of the params whereas the value is asking for the title of the task object.
Params are inputs that a server receives from a user. In Sinatra, they are a string with syntax relatable to a hash.

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