🕵️♀️ Task
You can limit the number of records in an ActiveRecord::Relation with .limit. You pass an Integer argument to choose the number of records you want to appear in the collection.
ActiveRecord::Relation
.limit
Integer
LevelUp
Selecting all records
Find one record by primary...
Counting records
Find record via index
Find record by position us...
Order records by column va...
Retrieving values from col...
Retrieve all values from a...
Limit number of selected r...
Offset selected records
Filtering records with whe...
Exclude records from result
Calculate minimum value in...
Calculate maximum value in...
Calculate average value in...
Calculate sum of values in...
Find the "many" side of a ...
Find the "one" side of one...
Many-to-many associations ...
0.0% complete
Select the first 2 records from the persons table
Person.all.limit(2) => #<Person::ActiveRecord_Relation:0x00007fa4341e1ee8>
Select the first 10 records from the dishes table
Dish.all.limit(10) => #<Dish::ActiveRecord_Relation:0x00007fa4341e1ee8>