Files
nairobi/app/models
Javi Martín 17f442c723 Extract method to get a few random records
In Ruby 5.2, we get a warning when using the "RANDOM()" function:

DEPRECATION WARNING: Dangerous query method (method whose arguments are
used as raw SQL) called with non-attribute argument(s): "RANDOM()".
Non-attribute arguments will be disallowed in Rails 6.0. This method
should not be called with user-provided values, such as request
parameters or model attributes. Known-safe values can be passed by
wrapping them in Arel.sql().

This warning doesn't make much sense, though, since RANDOM() is a common
function which is not dangerous at all. However, since the warning is
annoying, we'll probably have to find a way to deal with it.

So I'm extracting all our RANDOM() usages into a method. This way we'll
only have to change one method to avoid this warning.

I've chosen `sample` because it's similar to Ruby's Array#sample, and
because `order_by_random` would be confusing if we consider we already
have a method called `sort_by_random`.
2020-07-14 12:32:14 +02:00
..
2019-11-01 20:08:46 +01:00
2019-11-06 00:04:02 +01:00
2019-03-27 15:22:14 +01:00
2019-11-06 00:04:02 +01:00
2019-10-23 14:39:31 +02:00
2019-03-14 17:25:43 +01:00
2019-04-29 13:08:43 -05:00
2020-07-08 12:39:25 +02:00
2020-04-09 07:11:53 +10:00
2019-02-05 17:41:00 +01:00
2019-10-25 19:29:12 +02:00
2017-12-15 19:21:02 +01:00