🕵️‍♀️ Task

Order the records in the movies table by the year column in ascending order.

movies

  • id (integer)
  • title (string)
  • year (integer)
  • duration (integer)
  • description (text)
  • image (string)
  • director_id (integer)

directors

  • id (integer)
  • name (string)
  • dob (date)
  • bio (text)
  • image (string)

actors

  • id (integer)
  • name (string)
  • dob (date)
  • bio (text)
  • image (string)

characters

  • id (integer)
  • actor_id (integer)
  • movie_id (integer)
  • name (string)
📖Method

The .order method lets you sort your collection of records by one or more columns. .order can accept a Hash, String, or Arel as an argument.

Most commonly, we pass a Hash argument where the keys are the columns you want to sort by, and the value are either :asc (for ascending order) or :desc (for descending order).

class Movie < ActiveRecord::Base end
class Director < ActiveRecord::Base end
class Actor < ActiveRecord::Base end
class Character < ActiveRecord::Base end