В моем before_create
обратном вызове я CAN назначаю свой пользовательский GUID в производственных средах и средах разработки. Однако тот же код, запущенный в тестовой среде НЕ МОЖЕТ изменить значение моего пользовательского GUID. См. Пример кода ниже.
require 'rubygems'
require 'uuidtools'
require 'base32/crockford'
class WhatClass < ActiveRecord::Base
# Declare the non-standard column guid as the primary key
set_primary_key :guid
# Use a callback to generate the record id
before_create :create_uuid
private
# This method creates a universally unique identifier (UUID)
# for an instance of WhatClass. This method is called before the
# record is created.
def create_uuid
# Create the UUID
uuid = UUIDTools::UUID.sha1_create(UUIDTools::UUID_URL_NAMESPACE, "string-to-create-from")
self.guid = Base32::Crockford.encode(uuid.to_i)
end
end
Может кто-нибудь объяснить, почему self.guid
работает в производстве / разработке, а не в тесте?