aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods/primary_key.rb
diff options
context:
space:
mode:
authorJoost Baaij <joost@spacebabies.nl>2012-01-06 11:53:01 +0100
committerJoost Baaij <joost@spacebabies.nl>2012-01-06 11:53:01 +0100
commit621eb3b666f2df84b7d40d5074eb033204d38146 (patch)
tree3f2fd380732ed6bf52d524c72849618e89e0a4ee /activerecord/lib/active_record/attribute_methods/primary_key.rb
parent693a68f24b399cd86fa0daf010f408ab5d3b3aaf (diff)
downloadrails-621eb3b666f2df84b7d40d5074eb033204d38146.tar.gz
rails-621eb3b666f2df84b7d40d5074eb033204d38146.tar.bz2
rails-621eb3b666f2df84b7d40d5074eb033204d38146.zip
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).
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/primary_key.rb')
-rw-r--r--activerecord/lib/active_record/attribute_methods/primary_key.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb
index a7785f8786..7c59664703 100644
--- a/activerecord/lib/active_record/attribute_methods/primary_key.rb
+++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb
@@ -44,7 +44,8 @@ module ActiveRecord
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