use the schema cache when asking for the primary key

This commit is contained in:
Aaron Patterson
2011-12-12 15:58:39 -08:00
parent 400929fb44
commit d12e6d0e2f

View File

@@ -72,7 +72,7 @@ module ActiveRecord
when :table_name_with_underscore
base_name.foreign_key
else
if ActiveRecord::Base != self && connection.table_exists?(table_name)
if ActiveRecord::Base != self && connection.schema_cache.table_exists?(table_name)
connection.primary_key(table_name)
else
'id'