Coder Social home page Coder Social logo

arielvgrubbs / displaying-has-many-through-rails-lab Goto Github PK

View Code? Open in Web Editor NEW

This project forked from learn-co-curriculum/displaying-has-many-through-rails-lab

0.0 0.0 0.0 123 KB

License: Other

Ruby 83.28% JavaScript 1.32% CSS 1.37% HTML 11.67% CoffeeScript 1.27% SCSS 1.08%

displaying-has-many-through-rails-lab's Introduction

Displaying Has Many Through Rails Lab

Objectives

  1. Construct a bi-directional has many through.
  2. Query for associations via the belongs_to, has_many, and has_many through associations.
  3. Iterate over associations in a view and display associated data for a primary instance.
  4. Identify the join model in a has many through.

Overview

The poor doctors at Seattle Grace Hospital are so overworked that they're having trouble keeping track of their patients' appointments! Let's help them (and practice our associations) by building some associations and displaying the data.

greys-anatomy

Instructions

First, fork and clone this lab.

You'll need to create all of the migrations, models, controllers, and views for this lab.

NOTE: As with much of our Rails curriculum, remember to always use the --no-test-framework flag when you generate models, controllers, etc. That way, the Rails generators will not create additional tests on top of the test suite that already comes with the lesson. E.g., rails g model User username:string email:string --no-test-framework.

Additional note about routes and generators: We've written the routes for you in the config/routes.rb file, so be sure to use the --skip-routes flag. This prevents the Rails generators from adding any unnecessary routes. You can use however many flags you need in the generators, so something like rails g model Post title:string content:text --no-test-framework --skip-routes is perfectly valid. (If you want to see what other flags and options are available, you can run commands such as rails g --help and rails g model --help.)

  1. Create migrations and models for doctor, patient, and appointment. Because this is for a hospital, a doctor can have many patients, but a patient can also have many doctors. Patients and doctors both have many appointments. Our appointments table should have a column called appointment_datetime to represent the date and time the appointment will take place. (When you display this datetime, make sure it's in a human readable format. The tests will be expecting "January 12, 2016 at 3:00".)

  2. Create a Doctor#show page that displays the doctor's name, department, and appointments, with each appointment's date, time, and patient name (linking to the patient's show page).

  3. Create a Patient#show page that lists the date and time for each of their appointments and links to the corresponding doctor's show page.

  4. Create a Patient#index page that displays a link to each patient's show page and the total number of appointments they have.

  5. Create an Appointment#show page that shows the date, time, patient, and doctor for that particular appointment. Note that there should NOT be an Appointment#index page –– we don't want to have all of the appointments on display for anyone to see.

We've provided a seed file so you can have some data to play around with –– run rake db:seed once your migrations and models are complete.

displaying-has-many-through-rails-lab's People

Contributors

annjohn avatar arielvgrubbs avatar aviflombaum avatar blake41 avatar danielseehausen avatar gj avatar gnfisher avatar ipc103 avatar jjseymour avatar kwebster2 avatar lkwlala avatar maxwellbenton avatar peterbell avatar pletcher avatar rrcobb avatar sdcrouse 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.