Giter VIP home page Giter VIP logo

with_uuid's Introduction

HasUuid

Provides facilities to utilize UUIDs with ActiveRecord, including model and migration extensions.

Installation

Add this line to your application's Gemfile:

gem 'has_uuid'

And then execute:

$ bundle

Or install it yourself as:

$ gem install has_uuid

Usage

In a migration:

create_table "comments", :id => false, :force => true do |t|
  t.uuid     "id",      :primary_key => true 
  t.uuid     "post_id",                       :null => false
end

In a model:

class Posts < ActiveRecord::Base
  include WithUuid::Model

  # ...
end

with_uuid's People

Contributors

joshrieken avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

with_uuid's Issues

adapter_name failure with Rails-4.0.2

Trying to use with_uuid 0.2.0 with rails 4.0.2 and ruby 1.9.3, I built a simple test app model and migration:

class TestModel < ActiveRecord::Base
  include WithUuid::Model
end
class CreateTestModels < ActiveRecord::Migration
  def change
    create_table :test_models, id: false do |t|
      t.uuid :id, primary_key: true
      t.string :name

      t.timestamps
    end
  end
end

But running rake db:migrate results in the following error:

rake db:migrate
==  CreateTestModels: migrating ===============================================
-- create_table(:test_models, {:id=>false})
rake aborted!
An error has occurred, this and all later migrations canceled:

undefined method `adapter_name' for nil:NilClass/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/with_uuid-0.2.0/lib/with_uuid/extensions/migrations.rb:11:in `block in uuid'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/with_uuid-0.2.0/lib/with_uuid/extensions/migrations.rb:10:in `each'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/with_uuid-0.2.0/lib/with_uuid/extensions/migrations.rb:10:in `uuid'
/home/warlord/src/mocana/MDP/MDP/sources/Portal/TestApp/db/migrate/20131209212352_create_test_models.rb:4:in `block in change'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:184:in `create_table'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:625:in `block in method_missing'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:597:in `block in say_with_time'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:597:in `say_with_time'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:617:in `method_missing'
/home/warlord/src/mocana/MDP/MDP/sources/Portal/TestApp/db/migrate/20131209212352_create_test_models.rb:3:in `change'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:571:in `exec_migration'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:555:in `block (2 levels) in migrate'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:554:in `block in migrate'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:553:in `migrate'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:709:in `migrate'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:959:in `block in execute_migration_in_transaction'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:1005:in `block in ddl_transaction'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in `transaction'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:1005:in `ddl_transaction'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:958:in `execute_migration_in_transaction'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:920:in `block in migrate'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:916:in `each'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:916:in `migrate'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:764:in `up'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/migration.rb:742:in `migrate'
/home/warlord/.rvm/gems/ruby-1.9.3-p484@mdp/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.