Skip to content
This repository
Browse code

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...
commit 621eb3b666f2df84b7d40d5074eb033204d38146 1 parent 693a68f
Joost Baaij authored
3  activerecord/lib/active_record/attribute_methods/primary_key.rb
@@ -44,7 +44,8 @@ def dangerous_attribute_method?(method_name)
44 44
         end
45 45
 
46 46
         # Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the
47  
-        # primary_key_prefix_type setting, though.
  47
+        # primary_key_prefix_type setting, though. Since primary keys are usually protected from mass assignment,
  48
+        # remember to let your database generate them or include the key in +attr_accessible+.
48 49
         def primary_key
49 50
           @primary_key = reset_primary_key unless defined? @primary_key
50 51
           @primary_key

0 notes on commit 621eb3b

Please sign in to comment.
Something went wrong with that request. Please try again.