-
-
Save akitaonrails/937995 to your computer and use it in GitHub Desktop.
Revisions
-
rmoriz revised this gist
Apr 22, 2011 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,9 @@ module UUID included do set_primary_key 'uuid' before_create :generate_uuid def generate_uuid self.id = UUIDTools::UUID.random_create.to_s end end -
rmoriz revised this gist
Apr 22, 2011 . 2 changed files with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ # Gemfile … gem 'uuidtools' … This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ # db/migrate/20110422210841_create_sites.rb # 1. :id => false # 2. :uuid # -
rmoriz created this gist
Apr 22, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ … gem 'uuidtools' … This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # 1. :id => false # 2. :uuid # class CreateSites < ActiveRecord::Migration def self.up create_table(:sites, :id => false) do |t| t.string :uuid, :limit => 36, :primary => true t.timestamps end end def self.down drop_table :sites end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ # app/models/site.rb class Site < ActiveRecord::Base include Extensions::UUID end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # app/models/extensions/uuid.rb # module Extensions module UUID extend ActiveSupport::Concern included do set_primary_key 'uuid' def before_create self.id = UUIDTools::UUID.random_create.to_s end end end end