by nagnatron on 3/8/12, 11:08 AM with 11 comments
by JonWood on 3/8/12, 12:58 PM
by gcao on 3/9/12, 4:42 PM
class Request < ActiveRecord::Base
end
class RequestValidation < Aspector::Base
target do
def has_unique_hash_id?
exists?(:hash_id => hash_id)
end
end
before :create do
hash_id = SecureRandom.hex(12) until has_unique_hash_id?
end
endRequestValidation.apply(Request)
by soveran on 3/8/12, 2:48 PM
by bhousel on 3/8/12, 3:25 PM
Edit: Nevermind, I realize now that SecureRandom's uuid isn't really a uuid, in that sense. It's just random.