Git Product home page Git Product logo

phase-4-rails-routing-basics-lab's Introduction

Rails Routing Basics Lab

Learning Goals

  • Create a route
  • Map a route to a controller/action
  • Send JSON data as a response

Introduction

We'll continue building our API for viewing student data. In this lesson, we'll add some routes and controller logic for displaying data about our students.

To get set up, run:

$ bundle install
$ rails db:migrate db:seed

This will download all the dependencies for our app and set up the database.

Instructions

Index Route

  • Create a route for making a GET request to /students
  • Generate a StudentsController with an index action for handling the route; don't forget to pass the --no test framework argument!
  • In the index action, return JSON data representing a list of all students

Grades Route

  • Create a route for making a GET request to /students/grades
  • Add a grades action in the StudentsController for handling that route
  • In the grades action, return JSON data representing a list of all students, ordered by grade from highest to lowest

Bonus: Highest Grade Route

Un-comment out the last test in /spec/requests/students_spec.rb to complete the bonus.

  • Create a route for making a GET request to /students/highest-grade
  • Add a highest_grade action in the StudentsController for handling that route
  • In the highest_grade action, return JSON data representing the one student with the highest grade
  • Note: while the other two routes should return an array of data, this route should return just one student object!

Resources

phase-4-rails-routing-basics-lab's People

Contributors

ihollander avatar lizbur10 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.