Homework for 7A

Review

Complete Exit Ticket: http://ix-exit-tickets.herokuapp.com/

Topics Covered: Model, View, Controllers

Exercises

Note: All exercises must live inside of your s0203_exercises/firstname_lastname/d7 folder

While inside of your s0203_exercises directory, you can git add . then git commit -m "Helpful commit message here" and git push origin master to submit your homework to GitHub. (Don't forget to use git status along the way to check the state of your files in git)

Create a file called answers.md in your day7 folder to answer the following questions. Feel free to include images as well as text (Google how to do this in Markdown). Even if you're not sure about the answer, try your best! Feel free to write any lingering questions you have in the same file.

Conceptual Questions

Code Questions

# app.rb

require 'sinatra'

get '/' do
  erb :index
end

get '/heroes' do
  @heroes = ["Batman", "Superman", "Rogue", "Wolverine"]
  erb :heroes
end

get '/heroes/:hero' do
  heroes = {
            "Batman" => "batarang",
            "Superman" => "strength",
            "Rogue" => "flying",
            "Wolverine" => "claws"
            }
  @hero = params[:hero]
  @superpower = heroes[@hero]
  erb :hero
end

Short Answer

Pick 3 topics and write a short answer of what the topic is.

Topics

Project: Shark Watch (Optional Bonus)

You hear about the recent shark attack? We want to keep tabs on all the sharks in the area so all iX students are safe. Let's create a Shark Watch app to help us keep track of sharks.

Create a new rails app called shark_watch inside of your d7 folder with:

  1. 1 model Shark, with attributes name:string, size:integer, gender:string, and danger_level:integer.
  2. 1 controller sharks with actions index and show
  3. 2 views, index.html.erb which shows all the names of the sharks with a link to each individual shark, and show.html.erb, which displays all information pertaining to a specific shark.
  4. Save at least 3 instances of sharks in your database either through the rails console or seeds.rb.

Great work! Congrats on your second day of Rails!! Now add and commit your work then push it to GitHub :)