To Lecture Notes

IT 232 -- 10/14/15

Review Exercises

  1. What does the spaceship operator have to do with sorting objects?
    Ans: If <=> is defined for a model, then an array of objects from that model can be sorted with the Array sort method.
  2. How does has_and_belongs_to_many work?
    Ans: It defines a many-to-many relationship. For example, if a many-to-many relationship is defined for Student and Course using the table courses_students, then if s is a student object, s.courses returns an array of all of the courses in which the student s is enrolled. Similarly, if c is a course object, c.students returns an array of the students enrolled in the course c.

Project 3

More Examples

  1. Look at the LikesSite and LinkIcons Examples.

Using ActiveRecord