Совместим ли activeuuid и rails 4.1.1 или здесь что-то не так?

Вот небольшой фрагмент кода, который я пытаюсь использовать для реализации gem activeuuid:

Gemfile

source 'https://rubygems.org'
gem 'rails', '4.1.1'
gem 'pg'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'spring',        group: :development
gem 'activeuuid'

User.rb

class User < ActiveRecord::Base
  include ActiveUUID::UUID
end

Миграция xxxxxxxxx_create_users.rb

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users, :id => false  do |t|
      t.uuid :id, :primary_key => true
      t.string :email

      t.timestamps
    end
  end

  def self.down
    drop_table :users
  end

end

Выполнить простой запрос здесь невозможно даже после сборки или перезапуска консоли.

 2.1.1 :016 > User.all
    NoMethodError: undefined method `set_primary_key' for User (call 'User.connection' to establish a connection):Class
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activeuuid-ps-0.1.2/lib/activeuuid/uuid.rb:54:in `block in <module:UUID>'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activesupport-4.1.1/lib/active_support/concern.rb:120:in `class_eval'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activesupport-4.1.1/lib/active_support/concern.rb:120:in `append_features'
        from /home/sahil/projects/test_projects/myapp/app/models/user.rb:3:in `include'
        from /home/sahil/projects/test_projects/myapp/app/models/user.rb:3:in `<class:User>'
        from /home/sahil/projects/test_projects/myapp/app/models/user.rb:1:in `<top (required)>'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:443:in `load'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:443:in `block in load_file'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:633:in `new_constants_in'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:442:in `load_file'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:342:in `require_or_load'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:480:in `load_missing_constant'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:180:in `const_missing'
        from (irb):16
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/railties-4.1.1/lib/rails/commands/console.rb:90:in `start'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in `start'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:69:in `console'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

или даже

2.1.1 :029 >   User.count
    NoMethodError: undefined method `set_primary_key' for User (call 'User.connection' to establish a connection):Class
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
        from /home/sahil/.rvm/gems/ruby-2.1.1@myapp/gems/activeuuid-ps-0.1.2/lib/activeuuid/uuid.rb:54:in `block in <module:UUID>'
        ..........
        ..........
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

Что здесь происходит не так. Мне не хватает какой-то необходимой зависимости.


person Sahil Grover    schedule 16.05.2014    source источник


Ответы (1)


Нашел лучшее решение и реализовал его, как показано на странице: http://www.codesapling.com/blog/2014/05/24/using-uuid-as-primary-key-in-rails4-with-postgres/

person Sahil Grover    schedule 27.05.2014