The first thing I would suggest is that please upgrade your ruby and rails version.
A very good way of generating guid is SecureRandom, which is a ruby module. With easy usage.
require 'securerandom'
guid = SecureRandom.hex(10) #or whatever value you want instead of 10