Note: This guide will focus on forms; you can learn more about requests in Lecture Guide 1! Finally, In-Memory Models was never covered in class for it is just an extension of basic Ruby concepts. This guide adds some supplementary resources to help you get familiar with them 🙂

Learning Goals 🎯

  1. Be able to utilize form helpers to create a form in embedded ruby
  2. Understand how forms created with Rails form helpers automatically send a request with the parameters in a hash for you
  3. Understand how we can use basic Ruby language constructions (Objects, arrays, hashes) to store data in memory

Prerequisites 🤔

Interactive Templates Through Forms!

In Lecture Guide 2, we introduced the idea of templating: view files (specifically *.html.erb) that have embedded ruby to calculate values before sending it back to the browser. As a quick refresher, what this looks like is below:

<h1> <%= @name %> </h1>

The embedded ruby above will evaluate what @name is before it's inserted into the html. We're expected to set @name in the controller action that's linked to this template.

Today, we approach the question of how we can create a more interactive UI. Specifically, how do we include forms that the user can fill out? First, let's see what this looks like on the screen: