Skip to content

Instantly share code, notes, and snippets.

@JoelLindow
Last active June 27, 2017 16:54
Show Gist options
  • Save JoelLindow/ca0e64df83394e8a0f42cbf1358b2a1e to your computer and use it in GitHub Desktop.
Save JoelLindow/ca0e64df83394e8a0f42cbf1358b2a1e to your computer and use it in GitHub Desktop.
Crud CFU Questions
  1. Define CRUD.
  • Create
  • Read
  • Update
  • Delete
  • ^^ all possible database interactions
  1. Why do we use set method_override: true?
  • HTML does not support put or delete, so it allows us to override the existing method/verb.
  • It has something to do with making POST requests look like other request methods (like put or get).
  • When method override is true the method override parameter overrides the http method.
  • Allows non standard http requests. It's "kind of a hack".
  • It sneaks in "other verbs".
  • This issue sneaks up becasue you are constrained by forms. We are trying to create an app that foloows the convention of routes. There are HARD constraints but mostly just due to trying to follow convention. This is only used to modify or delete items in forms.
  1. Explain the difference between value and name in this line: .
  • THIS IS A FORMS THING!!!!!
  • name='task[title]' - Refers to your Params Hash
  • value="<%= @task.title %>"/> - value is the "starting value" which we manually made the task title!
  • Name lets us define the key. It's just text in this example, but it lets us define position of the "title". This is "hardcoded"
  • Value lets us define the value of the key. It's drawing on a value that was most likely set in the controller. It is "dynamically populated".
  • THIS IN AN INPUT LINE! KEEP THAT IN MIND!
  • Value = Returning the value of the title method being run on the task instance variable.
  • Value = Beths Answer - Sets the value according to this structure that we've set up............
  • Name = Is returning the value of the Title Key
  1. What are params? Where do they come from?
  • Params can come from forms, dynamic elements.
  • Params are variables that are created by the client
  • Params are a cluster of data passing between the browser (client) to the server. Client is where params are generated, and get combined with the request that gets sent to the server.
  • Params are basically the data being input from the user or from form entries. A parameter is a special kind of variable in computer programming language that is used to pass information between functions or procedures.
  1. Check out your routes. Why do we need two routes each for creating a new Task and editing an existing Task?
  • One is Updating existing data and the other is Creating new data.
  • One basically allows the client to create the data being used to submit the requests
  • The other returns or serves the response.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment