Browse files

Expanded rdoc about primary keys being protected from mass assignment.

People need to make sure they are generated internally or added to attr_accessible so they can be mass assigned (for instance, from an import job).
  • Loading branch information...
tilsammans committed Jan 6, 2012
1 parent 693a68f commit 621eb3b666f2df84b7d40d5074eb033204d38146
Showing with 2 additions and 1 deletion.
  1. +2 −1 activerecord/lib/active_record/attribute_methods/primary_key.rb
@@ -44,7 +44,8 @@ def dangerous_attribute_method?(method_name)
# Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the
- # primary_key_prefix_type setting, though.
+ # primary_key_prefix_type setting, though. Since primary keys are usually protected from mass assignment,
+ # remember to let your database generate them or include the key in +attr_accessible+.
def primary_key
@primary_key = reset_primary_key unless defined? @primary_key

0 comments on commit 621eb3b

Please sign in to comment.