Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 621eb3b666f2df84b7d40d5074eb033204d38146 1 parent 693a68f
@tilsammans tilsammans authored
View
3  activerecord/lib/active_record/attribute_methods/primary_key.rb
@@ -44,7 +44,8 @@ def dangerous_attribute_method?(method_name)
end
# 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
@primary_key
Please sign in to comment.
Something went wrong with that request. Please try again.