🕵️♀️ Task
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.
LevelUp
0.0% complete
LevelUp
0.0% complete
| id | title | year | duration | description | image | director_id | 
|---|---|---|---|---|---|---|
| 17 | Seven Samurai | 1954 | 207 | A poor village under attack... | http://ia.media-imdb.com/im... | 14 | 
| 18 | Forrest Gump | 1994 | 142 | Forrest Gump, while not int... | http://ia.media-imdb.com/im... | 15 | 
| 19 | The Matrix | 1999 | 136 | A computer hacker learns fr... | http://ia.media-imdb.com/im... | 16 | 
| 20 | The Lord of the Rings: The ... | 2002 | 179 | While Frodo and Sam edge cl... | http://ia.media-imdb.com/im... | 8 | 
| 21 | City of God | 2002 | 130 | Two boys growing up in a vi... | http://ia.media-imdb.com/im... | 17 | 
| 22 | Se7en | 1995 | 127 | Two detectives, a rookie an... | http://ia.media-imdb.com/im... | 9 | 
| 23 | The Silence of the Lambs | 1991 | 118 | A young F.B.I. cadet must c... | http://ia.media-imdb.com/im... | 18 | 
| 24 | Once Upon a Time in the West | 1968 | 175 | Epic story of a mysterious ... | http://ia.media-imdb.com/im... | 4 | 
| id | name | dob | bio | image | 
|---|---|---|---|---|
| 17 | Kátia Lund | http://ia.media-imdb.com/im... | ||
| 18 | Jonathan Demme | 1944-02-22 | http://ia.media-imdb.com/im... | |
| 19 | Michael Curtiz | 1886-12-24 | Curtiz began acting in and ... | http://ia.media-imdb.com/im... | 
| 20 | Bryan Singer | 1965-09-17 | http://ia.media-imdb.com/im... | |
| 21 | Alfred Hitchcock | 1899-08-13 | Alfred Hitchcock was the so... | http://ia.media-imdb.com/im... | 
| 22 | Frank Capra | 1897-05-18 | One of seven children, Fran... | http://ia.media-imdb.com/im... | 
| 23 | Luc Besson | 1959-03-18 | Luc Besson spent the first ... | http://ia.media-imdb.com/im... | 
| 24 | Billy Wilder | 1906-06-22 | Originally planning to beco... | http://ia.media-imdb.com/im... | 
| id | name | dob | bio | image | 
|---|---|---|---|---|
| 17 | Al Pacino | 1940-04-25 | Known for his forceful dram... | http://ia.media-imdb.com/im... | 
| 18 | James Caan | 1940-03-26 | A masculine and enigmatic a... | http://ia.media-imdb.com/im... | 
| 19 | Richard S. Castellano | 1933-09-04 | Bronx born, stocky Italian-... | http://ia.media-imdb.com/im... | 
| 20 | Robert Duvall | 1931-01-05 | Veteran actor and director ... | http://ia.media-imdb.com/im... | 
| 21 | Sterling Hayden | 1916-03-26 | Born to George & Frances Si... | http://ia.media-imdb.com/im... | 
| 22 | John Marley | 1907-10-17 | Veteran character actor Joh... | http://ia.media-imdb.com/im... | 
| 23 | Richard Conte | 1910-03-24 | Richard Conte was born Nich... | http://ia.media-imdb.com/im... | 
| 24 | Al Lettieri | 1928-02-24 | Menacing looking Italian Am... | http://ia.media-imdb.com/im... | 
| id | actor_id | movie_id | name | 
|---|---|---|---|
| 17 | 17 | 2 | Michael Corleone | 
| 18 | 18 | 2 | Sonny Corleone | 
| 19 | 19 | 2 | Clemenza (as Richard Castel... | 
| 20 | 20 | 2 | Tom Hagen | 
| 21 | 21 | 2 | Capt. McCluskey | 
| 22 | 22 | 2 | Jack Woltz | 
| 23 | 23 | 2 | Barzini | 
| 24 | 24 | 2 | Sollozzo | 
Retrieve the ages of each record in the persons table
Person.all.pluck(:age)
=> [42, 36, 22, 29, 27]
Retrieve the names of each record in the dishes table
Dish.all.pluck(:name)
=> ["Burger", "Mac & Cheese", "Kale Salad"]