🕵️‍♀️ Task

Select the first record from the movies table.

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

When called on an ActiveRecord::Relation, .first returns the first record from the collection. If the collection is empty, .first returns nil.

You can optionally pass an Integer argument to .first. This will return n number of records from the ActiveRecord::Relation. If the collection is empty when you pass an argument, .first returns an empty Array.

Similar methods exist for second, third, fourth, fifth, forty_two, last, second_to_last, and third_to_last.

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