🕵️‍♀️ Task

Select the records from the actors table that have played a character in the movie titled, Interstellar.

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

On an ActiveRecord::Relation, the pluck method will retrieve one or more attributes of each record in the collection and returns them in a Array. You can pass one or more Symbols as an argument. Each Symbol must match the name of a column.

where is used for filtering a collection of records down using various criteria. Most commonly, we pass a Hash argument. The key is the column you’re searching in and the value is what you’re trying to find in that column. The value could be any type of object, but the Class should usually match the type of column you’re searching in.


Returns a new relation, which is the result of filtering the current relation according to the conditions in the arguments. where accepts conditions in one of several formats.

Given a Hash argument, the keys are columns and the values are values to be searched for. Columns can be symbols or strings. Values can be single values, arrays, or ranges.

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