Ruby on rails ActiveRecord::语句无效未知列错误

Ruby on rails ActiveRecord::语句无效未知列错误,ruby-on-rails,ruby,activerecord,Ruby On Rails,Ruby,Activerecord,为什么这样做很好: Tag.create(game_id: 1, tagged: u) 但这是: tags = Tag.where(game_id: 1, tagged: u).includes(:tagged) 给出错误: ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'tags.tagged' in 'where clause': SELECT `tags`.* FROM `tags` WHERE `tags

为什么这样做很好:

Tag.create(game_id: 1, tagged: u)
但这是:

tags = Tag.where(game_id: 1, tagged: u).includes(:tagged)
给出错误:

ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'tags.tagged' in 'where clause': SELECT `tags`.* FROM `tags`  WHERE `tags`.`game_id` = 1 AND `tags`.`tagged` = 1
顺便说一句,
u
ActiveRecord::Base
subcass

标记
表格结构:

create_table :tags, force: true do |t|
    t.references :game
    t.references :tagged_by
    t.references :tagged
    t.timestamps
end
试着做

tags = Tag.includes(:tagged).where(game_id: 1, tagged_id: u.id)

taged
是否驻留在您的
tag
表格中您可以发布您的
tag
模型吗?同时显示表格结构