ruby on rails - ActiveRecord::StatementInvalid unknown column error -


why work fine:

tag.create(game_id: 1, tagged: u) 

but this:

tags = tag.where(game_id: 1, tagged: u).includes(:tagged) 

gives error:

activerecord::statementinvalid: mysql2::error: unknown column 'tags.tagged' in 'where clause': select `tags`.* `tags`  `tags`.`game_id` = 1 , `tags`.`tagged` = 1 

btw, u activerecord::base sublcass.

tag table structure:

create_table :tags, force: true |t|     t.references :game     t.references :tagged_by     t.references :tagged     t.timestamps end 

try doing

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

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -