User.count # => 0
User.sample => nil
User.count # => 100
User.sample => #<User id: 42, ...>
User.sample(2) => #<ActiveRecord::Relation [#<User id: 1>, #<User id: 42>]>
User.count # => 100
User.sample(200) => #<ActiveRecord::Relation [All Users but shuffled]>
More than 5 years have passed since last update.
[ANN] Active Sample - Sample functionality for Active Record
Last updated at Posted at 2016-05-05
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
00