Coder Social home page Coder Social logo

phase-3-practice-code-challenge-aliens-among-us's Introduction

Practice Code Challenge - Aliens Among Us

Learning Goals

  • Write Active Record Migrations
  • Connect between tables using Active Record Associations
  • Write class and instance methods using Active Record
  • Use Active Record to query the database

Introduction

Aliens are among us! And they're here in order to visit their human friends on the planet Earth. Build out the rest of this super secret app for the MIB so they can track different visitations by aliens and their human friends.

Getting started

run bundle install

Migrations

Create your migrations.

  • Aliens should have a name, a earth_disguise_name, a home_planet, and a light_years_to_home_planet

  • Earthlingsshould have a first_name, a last_name and a job

  • Visitations should have a date, an alien_id and an earthling_id

aliens Table

Column Type
name string
earth_disguise_name string
home_planet string
light_years_to_home_planet integer

earthlings Table

Column Type
first_name string
last_name string
job string

visitations Table

Column Type
date string OR datetime
alien_id integer
earthling_id integer

Relationship

  • What associations will this need?
  • (i.e. has_many, has_many through, and belongs_to)

Earthling

  • Earthling#visitations returns all the visitations for an earthling
  • Earthling#aliens returns every alien that has visited that earthling
  • Earthling#full_name returns the combination of the human's first name and last name
  • Earthling.filter_by_job(job) takes in a job as a string and returns all earthlings with the specified job

Alien

  • Alien#visitations returns all the visitations that alien has been involved in
  • Alien#earthlings returns every earthling the alien has visited
  • Alien#visit(earthling) takes in an instance of an earthling and creates a visitation linking that earthling and alien for today's date
  • Alien#total_light_years_traveled returns the light years from the alien's home planet multiplied by the number of visitations for that alien ... times two (because they have to travel both ways right?)
  • Alien.most_frequent_visitor returns the alien with the most visitations
  • Alien.average_light_years_to_home_planet returns the average distance for all aliens to their home planets

Visitation

  • Visitation#alien returns the alien involved in the visitation
  • Visitation#earthling returns the earthling involved in the visitation

phase-3-practice-code-challenge-aliens-among-us's People

Contributors

brewchetta 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.