Permalink
Browse files

Alias id= if necessary, rather than relying on method_missing

  • Loading branch information...
1 parent 1a4ea1b commit 8d59e0b2633c26f9de8942a2d676afe39b0ee3f8 @jonleighton jonleighton committed Sep 4, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 activerecord/lib/active_record/attribute_methods/write.rb
@@ -17,6 +17,10 @@ def define_method_attribute=(attr_name)
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

0 comments on commit 8d59e0b

Please sign in to comment.