Permalink
Browse files

A missing primary key column shouldn't raise an error when generating…

… its error message.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2837 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent d47f3bc commit c827b3f15cdf66da1d09eff5ad4878098933c7d6 @jeremy jeremy committed Nov 1, 2005
Showing with 3 additions and 1 deletion.
  1. +2 −0 activerecord/CHANGELOG
  2. +1 −1 activerecord/lib/active_record/base.rb
View
2 activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* A missing primary key column shouldn't raise an error when generating its error message. [Don Park <don.park@gmail.com>]
+
* Changed :dbfile to :database for SQLite adapter for consistency (old key still works as an alias) #2644 [Dan Peterson]
* Added migration support for Oracle #2647 [Michael Schoen]
View
2 activerecord/lib/active_record/base.rb
@@ -1139,7 +1139,7 @@ def initialize(attributes = nil)
def id
attr_name = self.class.primary_key
column = column_for_attribute(attr_name)
- raise ActiveRecordError, "No such primary key column #{attr_name} for table #{table_name}" if column.nil?
+ raise ActiveRecordError, "No such primary key column #{attr_name} for table #{self.class.table_name}" if column.nil?
define_read_method(:id, attr_name, column) if self.class.generate_read_methods
(value = @attributes[attr_name]) && column.type_cast(value)
end

0 comments on commit c827b3f

Please sign in to comment.