diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-10-05 18:11:25 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-10-05 20:21:21 +0100 |
commit | 64747654ca661d695622c0ad9e33b8d9e6df8048 (patch) | |
tree | 953314bcf3e51aa784a600cfe09bee7280e79743 /activerecord/lib/active_record/base.rb | |
parent | fd8f0b297822ba36002084faa36bd0320d3be4a7 (diff) | |
download | rails-64747654ca661d695622c0ad9e33b8d9e6df8048.tar.gz rails-64747654ca661d695622c0ad9e33b8d9e6df8048.tar.bz2 rails-64747654ca661d695622c0ad9e33b8d9e6df8048.zip |
Revert "Raise error on unknown primary key."
This reverts commit ee2be435b1e5c0e94a4ee93a1a310e0471a77d07.
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 137b4c6534..78159d13d4 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -708,7 +708,7 @@ module ActiveRecord #:nodoc: # Returns an array of column objects for the table associated with this class. def columns if defined?(@primary_key) - connection_pool.primary_keys[table_name] ||= @primary_key + connection_pool.primary_keys[table_name] ||= primary_key end connection_pool.columns[table_name] @@ -953,7 +953,7 @@ module ActiveRecord #:nodoc: # objects of different types from the same table. def instantiate(record) sti_class = find_sti_class(record[inheritance_column]) - record_id = sti_class.primary_key? && record[sti_class.primary_key] + record_id = sti_class.primary_key && record[sti_class.primary_key] if ActiveRecord::IdentityMap.enabled? && record_id if (column = sti_class.columns_hash[sti_class.primary_key]) && column.number? @@ -1941,9 +1941,8 @@ MSG # The primary key and inheritance column can never be set by mass-assignment for security reasons. def self.attributes_protected_by_default - default = [ inheritance_column ] - default << primary_key if primary_key? - default << 'id' unless primary_key? && primary_key == 'id' + default = [ primary_key, inheritance_column ] + default << 'id' unless primary_key.eql? 'id' default end |