Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rails中多对多多态关联中没有列错误_Ruby On Rails_Activerecord_Polymorphic Associations - Fatal编程技术网

Ruby on rails rails中多对多多态关联中没有列错误

Ruby on rails rails中多对多多态关联中没有列错误,ruby-on-rails,activerecord,polymorphic-associations,Ruby On Rails,Activerecord,Polymorphic Associations,书的模型是 class Book < ActiveRecord::Base has_many :tokens, :through => :taggings has_many :taggings, :as => :taggable end 您是否为您的关联创建了所有必要的列? 标记表的模式应该与此类似 create_table "taggings", force: :cascade do |t| t.integer "token_id",

书的模型是

class Book < ActiveRecord::Base
has_many :tokens, :through => :taggings
has_many :taggings, :as => :taggable
end

您是否为您的关联创建了所有必要的列? 标记表的模式应该与此类似

create_table "taggings", force: :cascade do |t|
    t.integer  "token_id",                  limit: 4
    t.integer  "taggable_id",               limit: 4
    t.string   "taggable_type",             limit: 255
    t.datetime "created_at",                null: false
    t.datetime "updated_at",                null: false
  end

我认为您缺少
标记id
列,或者忘记执行迁移。

您是否为关联创建了所有必需的列? 标记表的模式应该与此类似

create_table "taggings", force: :cascade do |t|
    t.integer  "token_id",                  limit: 4
    t.integer  "taggable_id",               limit: 4
    t.string   "taggable_type",             limit: 255
    t.datetime "created_at",                null: false
    t.datetime "updated_at",                null: false
  end

我认为您缺少
token\u id
列或忘记执行迁移。

您的模型是否包含
token\u id
列?您的模型是否包含
token\u id
列?
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: taggings.token_id: SELECT "tokens".* FROM "tokens" INNER JOIN "taggings" ON "tokens"."id" = "taggings"."token_id" WHERE "taggings"."taggable_id" = ? AND "taggings"."taggable_type" = ?
create_table "taggings", force: :cascade do |t|
    t.integer  "token_id",                  limit: 4
    t.integer  "taggable_id",               limit: 4
    t.string   "taggable_type",             limit: 255
    t.datetime "created_at",                null: false
    t.datetime "updated_at",                null: false
  end