If I wanted a random record from the table, I could use .sample normally.
python
irb(main):005:0> User.all.sample(1)
=> [#<User id: 5, name: 'aho'>]
The basics I didn't know soberly.
What exactly is ActiveRecord :: Relation? https://doruby.jp/users/whale/entries/ActiveRecord--Relation%E3%81%A8%E3%81%AF%E4%B8%80%E4%BD%93%E3%81%AA%E3%82%93%E3%81%AA%E3%81%AE%E3%81%8B
Recommended Posts