Week 5, Day 2
Block 1 & 2: Models with ActiveRecord
Resources:
Block 3 & 4: Full Stack Sinatra
We're going to build a CRUD app! Time to create some forms and make a user interface. In this lab, we're going to take our time to build a polished full stack Sinatra application. We will introduce a few new concepts along the way to help you organize your code.
Goals
- Restructure Sinatra apps for scalability
- Use Controllers to handle specific routes
- Create user interfaces to add/create/update/destroy items.
Block 4: Pair Programming Lab
Build it together! In a new repository called sinatra_coupons
- You're going to build a Coupon application using Sinatra MVC
- You'll need a database!
- And a table for Coupons attributes like
title
, description
, product
, discount_price
, expiration_date
- You'll also need to create a migrations.sql file.
- Now, using ActiveRecord and Sinatra - create an MVC app that lists out all of the coupons.
- Utilize controllers to accomplish this!
Notes
- You should have an
ApplicationController
, HomeController
, and CouponsController
- You'll also need a
CouponsModel
After Hours
We need moar reps. Let's run through our basic MVC process again before jumping into full CRUD actions tomorrow. Tonight, inside of 05_full_stack_with_sinatra/d02/your_name
create a new folder called Sinatra_Songs
.
- We need a database to store songs!
- Songs have
artist
and title
. Perhaps even a release_year
?
- Let's create a
Songs
table to store them.
- Now that we know this works, create a
migrations.sql
to store the connection/creation information regarding our database.
- Once our database is all set, create an application in Sinatra!
- This application should render all of the
songs
in our table on a page.
- Utilize Controllers, Models (and ActiveRecord) and Views (ERB) to render them out!
- Create a pull request once everything is up-and-running!