Sha256: 854aa15926310508416ad554e4e19a703b91b3f943ca913bcbd35e7635d6c76f
Contents?: true
Size: 432 Bytes
Versions: 2
Compression:
Stored size: 432 Bytes
Contents
# Patches ActiveRecord models to use UUID based IDs instead of the default numeric ones require 'uuidtools' # Extends ActiveRecord models with UUID based IDs module RestfulX::UUIDHelper def self.included(base) base.class_eval do before_create :generate_uuid end end # generates new UUID for the record def generate_uuid self.id = UUIDTools::UUID.random_create.to_s.gsub("-", "") unless self.id end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
restfulx-1.3.1 | lib/restfulx/active_record_uuid_helper.rb |
restfulx-1.3.0 | lib/restfulx/active_record_uuid_helper.rb |