Skip to content

Instantly share code, notes, and snippets.

@ckaminer
Forked from Carmer/crud.markdown
Last active May 10, 2016 22:31
Show Gist options
  • Save ckaminer/d691afed07fe1c57f7d9a41dcc63c460 to your computer and use it in GitHub Desktop.
Save ckaminer/d691afed07fe1c57f7d9a41dcc63c460 to your computer and use it in GitHub Desktop.
  1. Define CRUD.
  • Create, Read, Update, Delete
  1. 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 '/tasks' See all tasks
  • b. GET '/tasks/:id' See a single task
  • c. GET 'tasks/new' See form to enter a new task
  • d. POST '/tasks' Submit data to create a new task
  • e. GET '/tasks/:id/edit' Pull up a form (for specific id) in order to edit
  • f. PUT '/tasks/:id' Submit data (for specified id) from edit
  • g. DELETE '/tasks/:id' Delete a task
  1. Why do we use set method_override: true?
  • method_override allows us to use PUT and DELETE since GET and POST are the only default verbs.
  1. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>.
  • The name is outside of the box and is a set value, the value is what appears in the box (our actual data).
  1. What are params? Where do they come from?
  • Params is a hash that represents our database. Each item inside params is a hash that contains our data.
@ckaminer
Copy link
Author

Ready to be checked

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