From ebf618b7fc39d66852f666c12b79fd6e71da0e3a Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Thu, 13 Oct 2005 20:44:39 +0000 Subject: Delegate access to a customized primary key to the conventional id method. Closes #2444. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2569 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/base.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 3f0201a202..8af2c33ce5 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1331,6 +1331,8 @@ module ActiveRecord #:nodoc: if @attributes.include?(method_name) define_read_methods if self.class.read_methods.empty? && self.class.generate_read_methods read_attribute(method_name) + elsif self.class.primary_key.to_s == method_name + id elsif md = /(=|\?|_before_type_cast)$/.match(method_name) attribute_name, method_type = md.pre_match, md.to_s if @attributes.include?(attribute_name) -- cgit v1.2.3