aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-09-04 22:05:53 +0100
committerJon Leighton <j@jonathanleighton.com>2011-09-13 00:01:57 +0100
commit8d59e0b2633c26f9de8942a2d676afe39b0ee3f8 (patch)
tree89f3bfafc45b6ca393e19f5c2c6218c3f7933b9a /activerecord/lib
parent1a4ea1bc97f5a4f22d02edd36e701b6e495cf776 (diff)
downloadrails-8d59e0b2633c26f9de8942a2d676afe39b0ee3f8.tar.gz
rails-8d59e0b2633c26f9de8942a2d676afe39b0ee3f8.tar.bz2
rails-8d59e0b2633c26f9de8942a2d676afe39b0ee3f8.zip
Alias id= if necessary, rather than relying on method_missing
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/attribute_methods/write.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/write.rb b/activerecord/lib/active_record/attribute_methods/write.rb
index c77a3ac145..5621b44c8c 100644
--- a/activerecord/lib/active_record/attribute_methods/write.rb
+++ b/activerecord/lib/active_record/attribute_methods/write.rb
@@ -17,6 +17,10 @@ module ActiveRecord
write_attribute(attr_name, new_value)
end
end
+
+ if attr_name == primary_key && attr_name != "id"
+ generated_attribute_methods.module_eval("alias :id= :'#{primary_key}='")
+ end
end
end