Jim's
Tutorials

Spring 2018
course
site

Nate's Work

>>> [5] pry(main)> Classroom.first.students
  Classroom Load (0.5ms)  SELECT  "classrooms".* FROM "classrooms" ORDER BY "classrooms"."id" ASC LIMIT $1  [["LIMIT", 1]]
  Student Load (0.4ms)  SELECT "students".* FROM "students" WHERE "students"."classroom_id" = $1  [["classroom_id", 1]]
=> [#<Student:0x007ff646005520
  id: 1,
  name: "student1",
  classroom_id: 1,
  created_at: Tue, 10 Apr 2018 20:43:16 UTC +00:00,
  updated_at: Tue, 10 Apr 2018 20:43:16 UTC +00:00>,
 #<Student:0x007ff643083770
  id: 2,
  name: "student2",
  classroom_id: 1,
  created_at: Tue, 10 Apr 2018 20:43:16 UTC +00:00,
  updated_at: Tue, 10 Apr 2018 20:43:16 UTC +00:00>]



>>> Student.first.notes
  Student Load (0.5ms)  SELECT  "students".* FROM "students" ORDER BY "students"."id" ASC LIMIT $1  [["LIMIT", 1]]
  Note Load (0.5ms)  SELECT "notes".* FROM "notes" WHERE "notes"."student_id" = $1  [["student_id", 1]]
=> [#<Note:0x007ff641c91320
  id: 1,
  note: "student1 was physically violent toward student 2 at 10am today",
  title: "poor behavior",
  student_id: 1,
  created_at: Tue, 10 Apr 2018 20:43:16 UTC +00:00,
  updated_at: Tue, 10 Apr 2018 20:43:16 UTC +00:00>,
 #<Note:0x007ff63fda61b8
  id: 2,
  note: "student1 was great today!",
  title: "good b ehavior",
  student_id: 1,
  created_at: Tue, 10 Apr 2018 20:43:16 UTC +00:00,
  updated_at: Tue, 10 Apr 2018 20:43:16 UTC +00:00>]

this was the output:

>>> curl http://localhost:3000/api/v1/classrooms
[[{"id":1,"name":"Daniel's Classroom","created_at":"2018-04-10T20:43:16.168Z","updated_at":"2018-04-10T20:43:16.168Z"},{"id":2,"name":"Josh's Classroom","created_at":"2018-04-10T20:43:16.171Z","updated_at":"2018-04-10T20:43:16.171Z"},{"id":3,"name":"Terri's Classroom","created_at":"2018-04-10T20:43:16.173Z","updated_at":"2018-04-10T20:43:16.173Z"},{"id":4,"name":"Robyn's Classroom","created_at":"2018-04-10T20:43:16.175Z","updated_at":"2018-04-10T20:43:16.175Z"}],[{"id":1,"name":"student1","classroom_id":1,"created_at":"2018-04-10T20:43:16.204Z","updated_at":"2018-04-10T20:43:16.204Z"},{"id":2,"name":"student2","classroom_id":1,"created_at":"2018-04-10T20:43:16.209Z","updated_at":"2018-04-10T20:43:16.209Z"}],[{"id":1,"note":"student1 was physically violent toward student 2 at 10am today","title":"poor behavior","student_id":1,"created_at":"2018-04-10T20:43:16.225Z","updated_at":"2018-04-10T20:43:16.225Z"},{"id":2,"note":"student1 was great today!","title":"good b ehavior","student_id":1,"created_at":"2018-04-10T20:43:16.234Z","updated_at":"2018-04-10T20:43:16.234Z"}],[{"id":1,"date":"1999-01-08","attendance":"tardy","student_id":1,"created_at":"2018-04-10T20:43:16.252Z","updated_at":"2018-04-10T20:43:16.252Z"}]]%

Big json hash I'll never use but it's all there!

https://cs.marlboro.college /cours /spring2018 /jims_tutorials /web_tech /project_apr10
last modified Sun December 22 2024 5:55 am