0
爲什麼這項工作很好:的ActiveRecord :: StatementInvalid未知列錯誤
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
BTW,u
是ActiveRecord::Base
sublcass。
Tag
表結構:
create_table :tags, force: true do |t|
t.references :game
t.references :tagged_by
t.references :tagged
t.timestamps
end
是列'tagged'駐留在你的'tag'表 – 2013-05-08 19:28:21
您可以發佈您'Tag'模式? – pungoyal 2013-05-08 19:30:49
也顯示錶結構 – 2013-05-08 19:31:30