search for: random_create

Displaying 6 results from an estimated 6 matches for "random_create".

2013 Oct 25
6
Migrate postgresql database to uuid
...g data so i did like :- create_table :posts, :id => false do |t| t.string :uuid, :limit => 36, :primary => true end ActiveRecord::Base.class_eval do # old rails versions set_primary_key ''uuid'' before_create :generate_uuid def generate_uuid self.id = UUIDTools::UUID.random_create.to_s end end This is working for new data,now i want to migrate existing data with relation.for uuid they are using datatype as string,in postgresql the data type used for primary_key and foreign key is integer ,so if i am trying to change foreign key integer to string it is throwing error. Coul...
2006 Apr 04
3
uuidtools across processes
Hello, It seems that there is a small probability of collisions among uuid''s produced by uuidtools'' UUID.random_create() running in concurrent user processes on a host (fcgi)? The ~2 bytes extracted from the randomized clock_sequence make a collision unlikely. http://rubyforge.org/frs/download.php/8572/uuidtools-1.0.0.zip Do I miss something? DD -- Posted via http://www.ruby-forum.com/.
2012 Oct 17
1
generate 10 UUID records and save it it database in rails
...of UUId records(based on the selection of drop down) and save it in the database. Now I am generating only one unique id. Can this be done in the model in this way. Or do I need to write a helper file for that?? def generate_unique_token=(value) self.secret = Base64.encode64(UUIDTools::UUID.random_create)[0..8] end In my controller........... def create @secretcode= Secretcode.new(params[:secretcode]) @user= User.new(params[:user]) @secretcode.user_id=@user @secretcode.generate_unique_token=params[:secretcode][:secret] if @secretcode.valid? @secretcode.save red...
2006 Feb 22
4
UUIDTool and weird timestamp split error
Hi, I am using UUIDTools to generate my Guids. It works fine on my computer (Windows Xp), but doesn''t work on my host (TextDrive) The error is: Loading production environment. >> UUID.timestamp_create.to_s /sbin/ifconfig: Permission denied NoMethodError: private method `split'' called for nil:NilClass from ./script/../config/../config/../lib/uuidtools.rb:236:in
2008 Mar 02
0
Models are not initialised correctly with ''rake test'' in Merb 0.9.1
...Test::Unit as my testing framework and have the following model: class Item < Sequel::Model validates do presence_of( :name, :uuid, :vendor_id, :vendor_reference, :amount, :currency_code ) uniqueness_of( :uuid ) end def initialize( *args ) super( *args ) self.uuid = UUID.random_create.to_s end end As you can see I overwrite initialize to set up the UUID when the model is instantiated. In my tests I have the following method which sets up an Item: def generate_valid_new_item item = Item.new do |i| i.name = random_item_name i.description = random_description...
2008 Apr 03
1
Problem with UUID generated in partial not being unique
...). Unfortunately when I add a new product line (using RJS page.insert.html rendering a partial) the new lines added all have the same UUID. Here''s the code from the (top of the) partial - <tr class="order_product" id ="<%= if order_product.new_record? UUID.random_create.to_s else order_product.id.to_s end %>"> If we have a new product added then we generate a UUID. If it is in edit mode, and we have an existing database record we using the ID of the record as the ID. When I generate the page initially it puts one product li...