Rails and Cassandra error: NoMethodError: undefined method `unpack' for :subdomain:Symbol

Rails and Cassandra error: NoMethodError: undefined method `unpack' for :subdomain:Symbol

我正在尝试使用 Ruby 在 Rails 和 Cassandra 数据库上创建一个简单的应用程序。我正在使用 cequel gem 并且在安装 cequel 之后我创建了 2 个模型。博客和 Post。

Blog.rb

class Blog < ActiveRecord::Base
  include Cequel::Record
  key :subdomain, :text
  column :name, :text
  column :description, :text
end

Post.rb

class Post < ActiveRecord::Base
  include Cequel::Record
  belongs_to :blog
  key :id, :uuid
  column :title, :text
  column :body, :text
end

这些是 2 个迁移文件:

class CreateBlogs < ActiveRecord::Migration
  def change
    create_table :blogs do |t|
      t.text :name
      t.text :description

      t.timestamps null: false
    end
  end
end


class CreatePosts < ActiveRecord::Migration
  def change
    create_table :posts do |t|
      t.key :id
      t.key :timeuuid
      t.text :title
      t.text :body

      t.timestamps null: false
    end
  end
end

然后我尝试 运行 这个命令 rake cequel:migrate 以便将模型的模式与 cassandra 数据库中的模式同步,但是我得到这个错误:

NoMethodError: undefined method `unpack' for :subdomain:Symbol

我正在与: 卡桑德拉版本:2.0.11 Rails版本:4.2.4

Cequel 不是为在 ActiveRecord 模型中使用而设计的。
删除 ActiveRecord::Base 的继承并删除您的迁移。
然后再次运行rake cequel:migrate,一切正常。