This way screen reader users will know which record they're going to access when focusing on a link to a certain action. Otherwise they'd hear something like "Edit, link", and they wouldn't know which record they'll end up editing if they follow the link.
13 lines
260 B
Ruby
13 lines
260 B
Ruby
class ApplicationRecord < ActiveRecord::Base
|
|
include HumanName
|
|
self.abstract_class = true
|
|
|
|
def self.sample(count = 1)
|
|
if count == 1
|
|
reorder(Arel.sql("RANDOM()")).first
|
|
else
|
|
reorder(Arel.sql("RANDOM()")).limit(count)
|
|
end
|
|
end
|
|
end
|