Sha256: 23d9214a7b8af2470c1eadd68df3aa2c76b3e9855c80c4953d4933e42973056d
Contents?: true
Size: 1.15 KB
Versions: 7
Compression:
Stored size: 1.15 KB
Contents
# Copyright (c) 2005 Assembla, Inc. # # This plugin for ActiveRecord makes the "ID" field into a URL-safe GUID # It is a mashup by Andy Singleton <andy@assembla.com> that includes # * the UUID class from Bob Aman. # * the plugin skeleton from Demetrius Nunes # * the 22 character URL-safe format from Andy Singleton # You can get standard 36 char UUID formats instead # TODO: Auto-detect a character ID field and use a GUID in this case (DRY principle) # # This library is free software; you can redistribute it and/or modify it # under the terms of the MIT license. # # TO USE # Install as a plugin in the rails directory vendor/plugin/guid # define ID as char(22) # call "usesguid" in ActiveRecord class declaration, like # class Mymodel < ActiveRecord::Base # usesguid # # if your ID field is not called "ID", call "usesguid :column =>'IdColumnName' " # if you create your tables with migrations, you need to bypass the rails default primary key index. Do this: # create_table :mytable, :id => false do |t| # t.column :id, :string, :limit => 22 # ... more fields # end # execute "ALTER TABLE mytable ADD PRIMARY KEY (id)" require 'usesguid'
Version data entries
7 entries across 7 versions & 1 rubygems