Hi all, I think I have found a bug in ActiveRecord's handling of eager loading when using table_name_prefix. Here is a reduction of the problem : class Cheese < ActiveRecord::Base ## ## id SERIAL ## name VARCHAR(32) ## county_id INTEGER ## belongs_to :county def self.table_name_prefix "stuff_" end end class County < ActiveRecord::Base ## ## id SERIAL ## name VARCHAR(32) ## has_many :cheeses def self.table_name_prefix "stuff_" end end class CountyController < ApplicationController def index @counties = County.find( :all, :include => [ :cheeses ] ) end end Loading /county/index gives the following error. PGError: ERROR: column stuff_cheeses.stuff_county_id does not exist. Note that it is putting the table_name_prefix before the foreign key in the cheeses table, and it is this that I consider to the the bug. It doesn't happen if I don't use eager loading in the controller, that is, I can access a county's cheeses just fine in the view using something like @counties.first.cheeses. I've looked through the faults list on the RoR site, but I didn't find anything resembling this. Can someone confirm that this is indeed a bug? If so, I'll prepare a patch to fix the issue. Best Regards, Carl. -- TopTheTable.com - Fun and games for the World Cup 2006. It'll get you in trouble with your boss, promise.
on 2006-01-26 14:01