Coder Social home page Coder Social logo

activerecord-tvland-web-1116's Introduction

TV Land ActiveRecord Associations Lab

Objectives

  1. Create and modify tables using ActiveRecord migrations.
  2. Build associations between models using Active Record macros.

Overview

In this lab, we'll be working with a TV show domain model. We will have a show, network and character model. They will be associated in the following way:

  • An actor has many characters and has many shows through characters.
  • A character belongs to an actor and belongs to a show.
  • A show has many characters and has many actors through characters.

We've given you a few migrations in the db/migrate directory to create the networks and shows table, but you'll have to add additional tables and modify these existing tables as per the guidelines below.

Remember to run rake db:migrate in the terminal before you run your tests and after you make any new migrations!

Instructions

spec/actor_spec.rb and spec/character_spec.rb

  • Write a migration for the actors table. An actor should have a first_name and a last_name.
  • Write a migration for the characters table. A character should have a name and a show_idโ€“โ€“a character will belong to a show.
  • Associate the Actor model with the Character and Show model. An actor should have many characters and many shows through characters.
  • Write a method in the Actor class, #full_name, that returns the first and last name of an actor.
  • Write a method in the Actor class, #list_roles, that lists all of the characters that actor has.
  • Write a migration that adds the column catchphrase to your character model.
  • Define a method in the Character class, #say_that_thing_you_say, using a given character's catchphrase.

spec/show_spec.rb

  • Write a migration for the shows table. A show should have a name and a genre.
  • Create the neccesary associations between shows, networks, and characters.

Resources

View TV Land ActiveRecord Associations Lab on Learn.co and start learning to code for free.

activerecord-tvland-web-1116's People

Contributors

ahimmelstoss avatar annjohn avatar benjagross avatar changamanda avatar febbraiod avatar fislabstest avatar fs-lms-test-bot avatar jjseymour avatar jmburges avatar kaylee42 avatar limerentfox avatar pletcher avatar sarogers avatar scottcreynolds avatar sophiedebenedetto avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.