I always liked this one I wrote ages ago, to generate strong (at the time) passwords:
[code lang=“ruby”]
((33..126).map { |i| i.chr }).to_a.shuffle[0..14].join
[/code]
[code lang=“ruby”]
((33..126).map { |i| i.chr }).to_a.shuffle[0..14].join
[/code]
File.readlines('/usr/share/dict/words').map(&:strip).shuffle.first(5).map(&:capitalize).join
=> "PanChloroformateParoticTillotBrushoff"14.times.map { rand(33..126).chr }.shuffle.join
At any rate, would probably want to use https://ruby-doc.org/stdlib-2.5.1/libdoc/securerandom/rdoc/S... for password generation.
Also, I think you might just want an alphabet and use sample: https://ruby-doc.org/core-2.5.1/Array.html#method-i-sample
# unsure if you need a:
require 'securerandom'
(33..126).sample(14, random: SecureRandom).map(&:chr).join