【问题标题】:Rails and Cassandra error: NoMethodError: undefined method `unpack' for :subdomain:SymbolRails 和 Cassandra 错误:NoMethodError:未定义的方法 `unpack' for :subdomain:Symbol
【发布时间】:2015-10-26 19:53:09
【问题描述】:

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

博客.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

【问题讨论】:

    标签: ruby-on-rails cassandra cassandra-2.0


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2017-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-14
      • 1970-01-01
      • 2013-04-24
      • 1970-01-01
      相关资源
      最近更新 更多