ActiveRecord gives 'no such column' SQL error for simple has_many association?

It looks like you're changing the name of the primary key for some reason. Make sure your Game class doesn't have anything like: class Game.

Sadly the entire code of the Game class is there in the original post. :( I did a search through my project files, and the only time 'primary_key' and 'set_primary_key' show up is in the frozen rails gems. – TheAdmiral Jul 19 '10 at 14:57 I created a scratch Rails 2.3.5 project and generated a Game and Patch class like you have here, but it works fine.

What back-end are you using? This could be a problem with the DB. Can you replicate this with the sqlite3 engine, for example?

– tadman Jul 19 '10 at 15:08 1 I'm using rails 2.3.8 and sqlite3 at the moment… I did notice an update to the ruby-sqlite3 gem go past a little while ago, so that might have broken it. I'll have a go with MySQL and see what happens. – TheAdmiral Jul 19 '10 at 15:26 Getting exactly the same error using MySQL: Unknown column 'patches.

Game_true' in 'where clause': SELECT * FROM patches WHERE (patches. Game_true = 1) – TheAdmiral Jul 20 '10 at 10:55 1 Same here, these work fine for me, so the problem might be somewhere else in your codebase. Try temporarily removing your frozen rails, and see if it works, and if not, strip out any plugins, lib files, helpers, etc (in approximately that order) to see if the problem dissapears.

Either something is altering the behaviour of ActiveRecord, or something is altering the behaviour of your class. – jasonpgignac Jul 20 '10 at 16:00.

I don't think it's claiming that there's no column called "patches". SQLException: no such column: patches. Game_true: SELECT * FROM "patches" WHERE ("patches".

Game_true = 1) That should change where you need to go look.

Now that SQL should really say 'WHERE patches. Game_id = 1', unless I'm going mad. I have no idea why it's generating that SQL!

And the patches table has 'game_id' in the table, and 3 entries, all for the first game. If I get one of the Patches and go my_patch. Game, it returns the Game object it belongs to, with no problems.

Any help would be greatly appreciated!

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions